How to access values returned by R functions (to put into vectors)?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to access values returned by R functions (to put into vectors)?

Quin Wills
The question is general for all functions, but here is a specific example -

 

# For the logistic regression of the following correlated variables:

C <- c(457,   1371,   4113,  12339,  37017, 111051, 333153, 999459)

E <- c(0.003858377, 0.014334578, 0.014092836, 0.737950754, 0.996371828,
0.997482379, 1.005569257, 0.994382856)

 

#  The nls function:

A = nls(E~(Em*C^p)/(C50^p + C^p), start = list(Em=0.8, p=3, C50=1e3))

 

# Returns the following parameter estimates for Em, p and C50:

Nonlinear regression model

  model:  E ~ (Em * C^p)/(C50^p + C^p)

   data:  parent.frame()

          Em            p          C50

   0.9989113    4.7957189 9934.6481397

 residual sum-of-squares:  0.0002856567

 

How do I access these parameter values from this output/function so that it
would go into a vector c(Em,p,C50)?


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: How to access values returned by R functions (to put into vectors)?

Gabor Grothendieck
Try this:

coef(A)

On 2/13/06, Quin Wills <[hidden email]> wrote:

> The question is general for all functions, but here is a specific example -
>
>
>
> # For the logistic regression of the following correlated variables:
>
> C <- c(457,   1371,   4113,  12339,  37017, 111051, 333153, 999459)
>
> E <- c(0.003858377, 0.014334578, 0.014092836, 0.737950754, 0.996371828,
> 0.997482379, 1.005569257, 0.994382856)
>
>
>
> #  The nls function:
>
> A = nls(E~(Em*C^p)/(C50^p + C^p), start = list(Em=0.8, p=3, C50=1e3))
>
>
>
> # Returns the following parameter estimates for Em, p and C50:
>
> Nonlinear regression model
>
>  model:  E ~ (Em * C^p)/(C50^p + C^p)
>
>   data:  parent.frame()
>
>          Em            p          C50
>
>   0.9989113    4.7957189 9934.6481397
>
>  residual sum-of-squares:  0.0002856567
>
>
>
> How do I access these parameter values from this output/function so that it
> would go into a vector c(Em,p,C50)?
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: How to access values returned by R functions (to put into vectors)?

Wincent
In reply to this post by Quin Wills
06.02.14>whatyouwant<-coef(A)
06.02.14>whatyouwant
          Em            p          C50
   0.9989113    4.7957189 9934.6481222

2006/2/14, Quin Wills <[hidden email]>:

> The question is general for all functions, but here is a specific example -
>
>
>
> # For the logistic regression of the following correlated variables:
>
> C <- c(457,   1371,   4113,  12339,  37017, 111051, 333153, 999459)
>
> E <- c(0.003858377, 0.014334578, 0.014092836, 0.737950754, 0.996371828,
> 0.997482379, 1.005569257, 0.994382856)
>
>
>
> #  The nls function:
>
> A = nls(E~(Em*C^p)/(C50^p + C^p), start = list(Em=0.8, p=3, C50=1e3))
>
>
>
> # Returns the following parameter estimates for Em, p and C50:
>
> Nonlinear regression model
>
>   model:  E ~ (Em * C^p)/(C50^p + C^p)
>
>    data:  parent.frame()
>
>           Em            p          C50
>
>    0.9989113    4.7957189 9934.6481397
>
>  residual sum-of-squares:  0.0002856567
>
>
>
> How do I access these parameter values from this output/function so that it
> would go into a vector c(Em,p,C50)?
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

--
黄荣贵
Deparment of Sociology
Fudan University


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html