s-news
[Top] [All Lists]

trying to extract a response vector using multinom object

To: <s-news@lists.biostat.wustl.edu>
Subject: trying to extract a response vector using multinom object
From: "Jeff P. Hollenbeck" <Jeff.Hollenbeck@oregonstate.edu>
Date: Wed, 12 Mar 2008 10:46:38 -0800
Organization: Oregon State University
Hello S users,
 
This is probably a very simple problem, but I am not well versed in Splus.
 
I am trying to extract the response vector used to fit a multinom object.  Specifically, I'm trying to reconstruct the response vector by extracting the name of the data and the name of the response variable from the multinom object, then using them in combination to retrieve the response vector.  The code I'm trying to use is:
 
# Set up response variable name.
data <- multinom.model@call[[3]]
yvar <- multinom.model@formula[[2]]
varname <- as.character(paste(data, "$", yvar, sep="", collapse=""))
 
# Extract response (y) vector.
y <- get(varname, immediate=T)
 
I can get the data name and the y-response name to combine in the paste statement, but I'm clueless how to actually get the response vector with that information.
 
varname returns
 
> "LWD$FUNCTION"
 
which is what I think I want since the data frame is "LWD" and the response variable is called "FUNCTION".
 
y returns
 
> Problem in get(varname, immediate = T): Object "LWD$FUNCTION" not found
Use traceback() to see the call stack
 
definitely not what I was looking for.
 
Again, this is probably quite simple, but I'm stumped.
 
Thanks very much.
 
Jeff.
 
 
Jeff P. Hollenbeck
Dept. Forest Resources
Oregon State University
Corvallis OR 97330
Email: Jeff.Hollenbeck@oregonstate.edu
Phone: 541-737-5500
<Prev in Thread] Current Thread [Next in Thread>