On Tue, 24 Jun 2003 10:27:58 -0700, Mohammad Ehsanul Karim wrote:
> _________________________
> In R console (or S-plus commands), i wrote-
> >x <- c(104.1, 106.6, 105.5, 107.5, 109.6, 113.3, 115.5, 117.7,
> 119.9, 122.1, 124.3, 126.5, 128.2)
> >y <- c(53732, 52912, 57005, 61354, 67682, 71602, 71961, 75309,
> 82931, 93310, 102161, 103068, 108927)
> > summary ( lm ( formula = y ~ x ) )
> _________________________
> And the result was-
> _________________________
> Call:
> lm(formula = y ~ x)
>
> Residuals:
> Min 1Q Median 3Q Max
> -6902 -3997 1070 2603 4906
>
> Coefficients:
> Estimate Std. Error t value Pr(>|t|)
> (Intercept) -186075.0 16047.4 -11.60 1.65e-07 *** x 2279.4 138.7
> 16.44 4.33e-09 *** --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05
> `.' 0.1 ` ' 1
>
> Residual standard error: 4020 on 11 degrees of freedom Multiple
> R-Squared: 0.9609, Adjusted R-squared: 0.9573 F-statistic: 270.2 on
> 1 and 11 DF, p-value: 4.332e-009 _________________________
>
> Can anyone tell me what are the "Signif. codes"? I think i need a bit
> explanation about specifically each of them. Also what does those " * "
> mean?
>
> Also, is there any direct command to predict y for x = 110?
The significance codes are a means to quickly review, what may be long
lists of coefficients in the formatted output tables. Thus for each of
the two lines in the output that you have above, you can quickly see that
each one has three (3) stars to the right.
If you review the table of codes below the summary, you can see that a
code of "***" indicates that the p value for the coefficient is between 0
and 0.001.
If you would prefer to not have these display, in R, you can use the
command:
options(show.signif.stars = FALSE)
or include the above statement in your Rprofile.
More information is available in R using:
?options
In terms of predicting y from x, you can use the function predict().
In the example you have, you would do the following:
# Create x and y vectors
x <- c(104.1, 106.6, 105.5, 107.5, 109.6, 113.3, 115.5, 117.7, 119.9,
122.1, 124.3, 126.5, 128.2)
y <- c(53732, 52912, 57005, 61354, 67682, 71602, 71961, 75309, 82931,
93310, 102161, 103068, 108927)
#Now create the model object
mod.lm <- lm(y ~ x)
# Create a *data frame* with new values of x ensuring that the new values
# have the same column names as the original model, in this case 'x'.
new.x <- data.frame(x = 110)
# Now predict y based upon new x value(s)
predict(mod.lm, newdata = new.x)
[1] 64659.4
If you want to predict based upon more than one value of x, simply
construct the data frame appropriately:
new.x <- data.frame(x = c(108, 110, 115, 120))
predict(mod.lm, newdata = new.x)
1 2 3 4
60100.60 64659.40 76056.42 87453.44
In R, see ?predict for more information. Using predict(), you can also
get prediction and confidence limits for the regression model.
In general, given the software specific query, you might be better served
by posting to the R or S-Plus e-mail lists as appropriate for the specific
application that you are using, as there are non-trivial differences
between the two.
For R, go to http://www.r-project.org/ and click on "Mailing Lists" in the
left hand frame for more information on subscribing to 'r-help'. Also
reviewing the R FAQs on the main web site and some of the online
introductory materials would be helpful to you.
For S-Plus, information on the 's-news' list is available at
http://www.biostat.wustl.edu/s-news/
Both lists have searchable archives as well.
HTH,
Marc Schwartz
.
.
=================================================================
Instructions for joining and leaving this list, remarks about the
problem of INAPPROPRIATE MESSAGES, and archives are available at:
. http://jse.stat.ncsu.edu/ .
=================================================================