17 observation two variable.Now y is dependent on x

 17 observation of two variables.Now y is dependent on x.

package ‘alr3’ successfully unpacked and MD5 sums checked
package ‘alr3’ was built under R version 3.6.2
> data("snake")
> head(snake)
     X    Y
1 23.1 10.5
2 32.8 16.7
3 31.8 18.2
4 32.0 17.0
5 30.4 16.3
6 24.0 10.5
> dim(snake)
[1] 17  2
> There are 17 observation  two variable.Now y is dependent on x.
Error: unexpected symbol in "There are"
> change x  and y into meaning ful variable.names()
Error: unexpected symbol in "change x"
> name(snake)=c(content', 'yield')
Error: unexpected string constant in "name(snake)=c(content', '"
> name(snake)=c('content', 'yield')
Error in name(snake) = c("content", "yield") :
  could not find function "name<-"
> name(snake)=c("content", "yield")
Error in name(snake) = c("content", "yield") :
  could not find function "name<-"
> names(snake) = c("content", "yield")
> attach(snake) #reattach data with new names
>
> head(snake)
  content yield
1    23.1  10.5
2    32.8  16.7
3    31.8  18.2
4    32.0  17.0
5    30.4  16.3
6    24.0  10.5
>
> plot(content, yield, xlab="water content of snow", ylab="water yield")
> A linear regression in R, one uses the lm() function to create a model in the
> standard form of fit = lm(Y~X).
> yield.fit = lm(yield~content)
>
> summary(yield.fit)

Call:
lm(formula = yield ~ content)

Residuals:
    Min      1Q  Median      3Q     Max
-2.1793 -1.5149 -0.3624  1.6276  3.1973

Coefficients:
            Estimate Std. Error t value Pr(>|t|) 
(Intercept)  0.72538    1.54882   0.468    0.646 
content      0.49808    0.04952  10.058 4.63e-08 ***
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.743 on 15 degrees of freedom
Multiple R-squared:  0.8709, Adjusted R-squared:  0.8623
F-statistic: 101.2 on 1 and 15 DF,  p-value: 4.632e-08
> Looking at the parameter estimates,
> the model tells us that the yield is equal to 0.72538 plus 0.49808 times the content. It
> can be stated that for every one unit change in the content, the yield will increase by
> 0.49808 units. F-statistic is used to test the null hypothesis that the model coefficients
> are all 0.
> The interpretation in
> this case is that 87 percent of the variation in the water yield can be explained by the
> water content of snow.
> We can recall our scatterplot, and now add the best fit line produced by our model
> plot(content, yield)
>
> abline(yield.fit, lwd=3, col="red")
>
> A linear regression model is only as good as the validity of its assumptions
> par(mfrow=c(2,2))
>
> plot(yield.fit)
> qqPlot(yield.fit)
[1]  7 10

There are 17 observation  two variable.Now y is dependent on x.

> set.seed(123)
> ma.sim = arima.sim(list(order=c(0,0,1), ma=-0.5), n=200)
>
> plot(ma.sim)
>
> acf(ma.sim)
> pacf(ma.sim)
two variable.Now y is dependent on x.

Reactions

Post a Comment

0 Comments