Question

In: Statistics and Probability

1) For your sample, use R to find the mean of x, the mean of y,...

1) For your sample, use R to find the mean of x, the mean of y, the standard deviation of x, the standard deviation of y, and the correlation between x and y. (You must give R code for credit.)

> set.seed(0003653838)

> x=rnorm(500)

> y=2*x+rnorm(500)

> Xbar=mean(x)

> Xbar

[1] 0.0712552

> Ybar=mean(y)

> Ybar

[1] 0.2370446

> sdx=sd(x)

> sdx

[1] 0.9841084

> sdy=sd(y)

> sdy

[1] 2.277837

> corxy=cor(x,y)

> corxy

[1] 0.9040743

2) Find the equation of the regression line to predict y from x.

> lm(y~x)

Call:

lm(formula = y ~ x)

Coefficients:

(Intercept)            x

    0.08794      2.09259

Y = -0.08794 + 2.09259*x

3) We select a point (x1,y1) from the parent population of your data. Suppose x = 1. What is the probability that y is greater than 3? (You may find this either by using theory or based on your data.)

4) Find a 95% confidence interval for the slope coefficient of the regression line predicting y from x.

> confint(lm(y~x), level = 0.95)

                  2.5 %    97.5 %

(Intercept) 0.002089795 0.1737838

x           2.005495780 2.1796802

The 95% confidence interval is (2.005, 2.180)

** I believe my answers are correct for Questions 1, 2 and 4. I am stuck on #3, so please help with that and provide any suggestions if I have missed anything on the other three questions.

Solutions

Expert Solution

Here I write R- for above problem as:

x=rnorm(500)

y=2*x+rnorm(500)

xbar=mean(x)

xbar

ybar=mean(y)

ybar

sdx=sd(x)

sdx

sdy=sd(y)

sdy

corxy=cor(x,y)

corxy

l=lm(y~x)

summary(l)

confint(l,level=0.95)

And the output is:

$Rscript main.r
[1] -0.02588524
[1] -0.05605924
[1] 1.019452
[1] 2.219479
[1] 0.8981331

Call:
lm(formula = y ~ x)

Residuals:
     Min       1Q   Median       3Q      Max 
-3.00930 -0.68355  0.00277  0.61991  2.64296 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) -0.005444   0.043704  -0.125    0.901    
x            1.955352   0.042899  45.580   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.9769 on 498 degrees of freedom
Multiple R-squared:  0.8066,    Adjusted R-squared:  0.8063 
F-statistic:  2078 on 1 and 498 DF,  p-value: < 2.2e-16

Error in confin(l, level = 0.95) : could not find function "confin"
Execution halted

Also for third question The R-code is:

x=rnorm(500)

y=rnorm(500)

z={}

for(i in 1:500)

{

if(x[i]==1&&y[i]<=3){z[i]=1}

else{z[i]=0}

}

p=sum(z)/500

p

Thus we get probability is 0.


Related Solutions

Consider the following utility function U(x,y)=x^r+y^r,0<r<1   Find the income effect and substitution effect?  ...
Consider the following utility function U(x,y)=x^r+ y^r,0<r<1   Find the income effect and substitution effect?   Does the substitution effect increase or decrease when r increases?
. Let x, y ∈ R \ {0}. Prove that if x < x^(−1) < y...
. Let x, y ∈ R \ {0}. Prove that if x < x^(−1) < y < y^(−1) then x < −1.
find a particular solution y”+y’+y=x+1 and y"+y'=x+1
find a particular solution y”+y’+y=x+1 and y"+y'=x+1
Find the positive numbers x, y and z whose sum is 100 such that x^r y^s...
Find the positive numbers x, y and z whose sum is 100 such that x^r y^s z^t is a maximum, where r, s and t are constants.
Let A = R x R, and let a relation S be defined as: “(x​1,​ y​1)​...
Let A = R x R, and let a relation S be defined as: “(x​1,​ y​1)​ S (x​2,​ y​2)​ ⬄ points (x​1,​ y​1)​ and (x​2,​ y​2)​are 5 units apart.” Determine whether S is reflexive, symmetric, or transitive. If the answer is “yes,” give a justification (full proof is not needed); if the answer is “no” you ​must​ give a counterexample.
Consider the formula A : ∃x.[(∀y.P(x, y) → R(x)) → ¬∃z.Q(x, z)] (a) Find a formula...
Consider the formula A : ∃x.[(∀y.P(x, y) → R(x)) → ¬∃z.Q(x, z)] (a) Find a formula equivalent to A that only has negation symbols in front of basic formulas. (b) Give an example of an interpretation where A is true. The domain should be the set N. (c) Give an example of an interpretation where A is false. The domain should be the set N.
Determine whether each statement is true or false, and prove or disprove, as appropriate. (a) (∀x∈R)(∃y∈R)[xy=1].(∀x∈R)(∃y∈R)[xy=1]....
Determine whether each statement is true or false, and prove or disprove, as appropriate. (a) (∀x∈R)(∃y∈R)[xy=1].(∀x∈R)(∃y∈R)[xy=1]. (b) (∃x∈R)(∀y∈R)[xy=1].(∃x∈R)(∀y∈R)[xy=1]. (c) (∃x∈R)(∀y∈R)[xy>0].(∃x∈R)(∀y∈R)[xy>0]. (d) (∀x∈R)(∃y∈R)[xy>0].(∀x∈R)(∃y∈R)[xy>0]. (e) (∀x∈R)(∃y∈R)(∀z∈R)[xy=xz].(∀x∈R)(∃y∈R)(∀z∈R)[xy=xz]. (f) (∃y∈R)(∀x∈R)(∃z∈R)[xy=xz].(∃y∈R)(∀x∈R)(∃z∈R)[xy=xz]. (g) (∀x∈Q)(∃y∈Z)[xy∈Z].(∀x∈Q)(∃y∈Z)[xy∈Z]. (h) (∃x∈Z+)(∀y∈Z+)[y≤x].(∃x∈Z+)(∀y∈Z+)[y≤x]. (i) (∀y∈Z+)(∃x∈Z+)[y≤x].(∀y∈Z+)(∃x∈Z+)[y≤x]. (j) (∀x,y∈Z)[x<y⇒(∃z∈Z)[x<z<y]].(∀x,y∈Z)[x<y⇒(∃z∈Z)[x<z<y]]. (k) (∀x,y∈Q)[x<y⇒(∃z∈Q)[x<z<y]].(∀x,y∈Q)[x<y⇒(∃z∈Q)[x<z<y]].
Consider the function ?(?,?)=3?^2−4?+??^2 on the closed region ?={(?,?):−1≤?≤1 and −1≤?≤1}R={(x,y):−1≤x≤1 and −1≤y≤1}. (a) Find all...
Consider the function ?(?,?)=3?^2−4?+??^2 on the closed region ?={(?,?):−1≤?≤1 and −1≤?≤1}R={(x,y):−1≤x≤1 and −1≤y≤1}. (a) Find all critical points of ?(?,?)f(x,y) in the region ?R, if any, and classify them (local maximum, local minimum, or saddle point). (b) Determine the absolute maximum and absolute minimum of ?(?,?)f(x,y) on the closed region ?R, and all points at which they occur.
Use variation of parameters to find a particular solution to the variable coeff. differential equation: y''+(2/x)y'+y=(1/x)...
Use variation of parameters to find a particular solution to the variable coeff. differential equation: y''+(2/x)y'+y=(1/x) Also find a general solution to this equation.
Use MuPAD to find the point on the line y = 2 – x/3 that is closest to the point x = -3, y = 1.
Use MuPAD to find the point on the line y = 2 – x/3 that is closest to the point x = -3, y = 1.  
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT