[R] Subsetting a named list of parameters in mle
Bert Gunter
gunter.berton at gene.com
Sat Feb 15 18:03:06 CET 2014
fit is initialized as a vector of integers. How can you assign an mle
fit to an element of an integer vector?
Initialize fit as a list, use lapply, or whatever. Have you read An
Intro to R (ships with R) or other R (e.g. web) tutorial? This looks
like the sort of basic misunderstanding that one who has not made much
effort to learn how R works would make.If not, please do so before
posting further.
Cheers,
Bert
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch
On Sat, Feb 15, 2014 at 5:38 AM, John Hodgson <john at formby.plus.com> wrote:
> I have a 7-parameter model to fit using mle. I would like to generate
> fits for all
> pairs of parameters (with others fixed)
>
> The following code looked like it should work:
>
> library(stats4)
>
> # dummy mll function for sake of example
> mll = function (lnk=1.5,lnhs=-5,lnhi=-5,lnss=-5,lnsi=-5,lnws=-5,lnwi=-5)
> lnk^2 + lnhs^2 + lnhi^2+ lnss^2 + lnsi^2+ lnws^2 + lnwi^2
>
> fit=1:6
> pars = list(lnk=1.5,lnhs=-5,lnhi=-5,lnss=-5,lnsi=-5,lnws=-5,lnwi=-5)
>
> for (i in 2:7) {
> fit[i] = mle(mll,start=pars[c(1,i)],fixed=
> pars[-c(1,i)],method="Nelder")
> }
>
>
> but it gives the following error:
> }
> Error in fit[i] = mle(mll, start = pars[c(1, i)], fixed = pars[-c(1,
> i)], :
> incompatible types (from S4 to integer) in subassignment type fix
>
> What have I missed?
>
> Thanks for any suggestions
>
> John Hodgson
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list