The R Project SVN R

Rev

Rev 70511 | Rev 78234 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 70511 Rev 76414
Line 121... Line 121...
121
## We first use the plinear algorithm to fit an overall model,
121
## We first use the plinear algorithm to fit an overall model,
122
## ignoring that alpha and beta might vary with Strip.
122
## ignoring that alpha and beta might vary with Strip.
123
 
123
 
124
musc.1 <- nls(Length ~ cbind(1, exp(-Conc/th)), muscle,
124
musc.1 <- nls(Length ~ cbind(1, exp(-Conc/th)), muscle,
125
              start = list(th = 1), algorithm = "plinear")
125
              start = list(th = 1), algorithm = "plinear")
-
 
126
## IGNORE_RDIFF_BEGIN
126
summary(musc.1)
127
summary(musc.1)
-
 
128
## IGNORE_RDIFF_END
127
 
129
 
128
## Then we use nls' indexing feature for parameters in non-linear
130
## Then we use nls' indexing feature for parameters in non-linear
129
## models to use the conventional algorithm to fit a model in which
131
## models to use the conventional algorithm to fit a model in which
130
## alpha and beta vary with Strip.  The starting values are provided
132
## alpha and beta vary with Strip.  The starting values are provided
131
## by the previously fitted model.
133
## by the previously fitted model.
132
## Note that with indexed parameters, the starting values must be
134
## Note that with indexed parameters, the starting values must be
133
## given in a list (with names):
135
## given in a list (with names):
134
b <- coef(musc.1)
136
b <- coef(musc.1)
135
musc.2 <- nls(Length ~ a[Strip] + b[Strip]*exp(-Conc/th), muscle,
137
musc.2 <- nls(Length ~ a[Strip] + b[Strip]*exp(-Conc/th), muscle,
136
              start = list(a = rep(b[2], 21), b = rep(b[3], 21), th = b[1]))
138
              start = list(a = rep(b[2], 21), b = rep(b[3], 21), th = b[1]))
-
 
139
## IGNORE_RDIFF_BEGIN
137
summary(musc.2)
140
summary(musc.2)
-
 
141
## IGNORE_RDIFF_END
138
options(od)
142
options(od)
139
 
143
 
140
# princomp.Rd
144
# princomp.Rd
141
## Robust:
145
## Robust:
142
(pc.rob <- princomp(stackloss, covmat = MASS::cov.rob(stackloss)))
146
(pc.rob <- princomp(stackloss, covmat = MASS::cov.rob(stackloss)))