Thanks Josh.

The variance of predictor should be var(beta_0+beta_1*newdata+epsilon). It
is actually the variance of dependent variable if we plug the concrete value
of independent variable into the model.



On Mon, Sep 27, 2010 at 2:09 PM, Joshua Wiley <jwiley.ps...@gmail.com>wrote:

> Hi,
>
> Try this:
>
> # using the iris dataset
> mydat <- iris
> mymodel <- lm(Sepal.Length ~ Petal.Length + Species, data = mydat)
> summary(mymodel)
> newdat <- data.frame(Petal.Length = seq(1, 10, by = .1),
>                     Species = factor(rep("virginica", 91)))
>
> results <- predict(object = mymodel, newdata = newdat, se.fit = TRUE)
>
> results
>
> The main lesson is that generally newdata should be a data frame with
> columns that have the same name as the predictors (IVs) in your model.
>  I'm not exactly sure what you mean by "variance of dependent variable
> based on model".  Do you want its total variance, residual variance,
> _______ ?
>
> Cheers,
>
> Josh
>
> On Mon, Sep 27, 2010 at 12:58 PM, Yi Du <abraham...@gmail.com> wrote:
> > Hi folks,
> >
> > I use lm to run regression and I don't know how to predict dependent
> > variable based on the model.
> >
> > I used predict.lm(model, newdata=80), but it gave me warnings.
> >
> > Also, how can I get the variance of dependent variable based on model.
> > Thanks.
> >
> >        [[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.
> >
>
>
>
> --
> Joshua Wiley
> Ph.D. Student, Health Psychology
> University of California, Los Angeles
> http://www.joshuawiley.com/
>

        [[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