[Date Index]
[Thread Index]
[Author Index]
Re: a mahtematica newbie about FitResiduals question:
*To*: mathgroup at smc.vnet.net
*Subject*: [mg67307] Re: [mg67264] a mahtematica newbie about FitResiduals question:
*From*: Darren Glosemeyer <darreng at wolfram.com>
*Date*: Sat, 17 Jun 2006 04:36:35 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
At 06:30 AM 6/14/2006 -0400, William wrote:
>hi:
>in mathematica ,I am learn the regression,.I see the help browser and
>can't understand the
> calculate.
>
>
>in the Statistics`LinearRegression` example of mathematica help
>browser
>
>this example please see the picture URL:
>http://lh3.google.com/william.wang/RI_KTKEfABI/AAAAAAAAAAY/02gUyKu1iMk/se.jpg?imgmax=1024
>
>
>what mean the SE? Standard Error?
>
>how to calculate the SE? by given Objserved and Prdicted value?
>
>I can get same result with the example SE result.
>
>from Standard Error formula that Predicted value minus Observed value
>then squared
> or by Residual error and Standard Error relationship formula.
>
>
>thanks.
Single prediction standard errors are a combination of the variation in the
data and the standard errors of the parameters in the model. The following
will show a couple of ways to obtain the first standard error in the
table. The rest can be obtained by following these steps with the other
data points.
In[1]:= << Statistics`
In[2]:= data = {{0.055, 90}, {0.091, 97}, {0.138, 107}, {0.167, 124}, {0.182,
142}, {0.211, 150}, {0.232, 172}, {0.248, 189}, {0.284,
209}, {0.351,
253}};
For the first way of computing the standard error, we will need the
estimated variance and the covariance matrix.
In[3]:= {estvar, covmat} = ({EstimatedVariance, CovarianceMatrix} /.
Regress[data, {1, x^2}, x,
RegressionReport -> {CovarianceMatrix,
EstimatedVariance}] /.
MatrixForm -> Identity)
Out[3]= {64.9129, {{17.7381, -247.146}, {-247.146, 5430.96}}}
The coefficients for the model for the first data point are 1 and x^2 where
x is the first predictor value in data.
In[4]:= coeffs1 = {1, data[[1, 1]]^2}
Out[4]= {1, 0.003025}
The standard error is the following.
In[5]:= Sqrt[estvar + coeffs1.covmat.coeffs1]
Out[5]= 9.01141
For other models, the formula above with the coefficients replaced with the
appropriate coefficients for the given model will work for any number of
predictors. The terms in the Sqrt take into account the variance of the
data, the variances of the parameter estimates and the covariances between
parameter estimates.
With two parameters, as in the example, the standard error can be computed
from the fitted values, the mean response, and the estimated variance as
follows.
In[6]:= fitted = PredictedResponse /.
Regress[data, {1, x^2}, x, RegressionReport ->
{PredictedResponse}];
In[7]:= responsemean = Mean[data[[All, -1]]];
In[8]:= datalen = Length[data];
In[9]:= Sqrt[estvar((datalen + 1)/datalen + (fitted[[1]] - responsemean)^2/
Total[(fitted - responsemean)^2])]
Out[9]= 9.01141
With a larger number of fitted parameters the variances and covariances
would need to be enumerated. The approach in In[5] takes all of this into
account within the dot products, so it is easier to use that than to
explicitly write out all of the variance and covariance terms.
Darren Glosemeyer
Wolfram Research
Prev by Date:
**Re: standard errors and confidence intervals in NonlinearRegress**
Next by Date:
**GraphPlot question**
Previous by thread:
**a mahtematica newbie about FitResiduals question:**
Next by thread:
**dynamic variable definiton**
| |