Hi, everyone,

Night. I have three questions about multiple linear regression in R.

Q1:

y=rnorm(10,mean=5)
x1=rnorm(10,mean=2)
x2=rnorm(10)
lin=lm(y~x1+x2)
summary(lin)

## In the summary, 'Residual standard error: 1.017 on 7 degrees of freedom',
1.017 is the estimate of the constance variance?

Q2:

beta0=lin$coefficients[1]
beta1=lin$coefficients[2]
beta2=lin$coefficients[3]

y_hat=beta0+beta1*x1+beta2*x2

## Is there any built-in function in R to obtain y_hat directly?

Q3:

If I want to apply this regression result to another dataset, that is, new
x1 and x2. Is the built-in function in 2 still available?

Thank you in advance!

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to