Skip to content

replacement has *** rows, data has ***

3 messages · Manqing Liu, William Dunlap, David Winsemius

#
Hi all,

I created a predicted variable based on a model, but somehow not all
observations have a predicted value. When I tired to add the predicated
value to the main data set (data$pr <- pr) , it said:
replacement has 34333 rows, data has 34347.
Do you know how to solve that?

Thanks,
Manqing
#
This can happen if there are rows containing missing values (NA's) in the
data used to fit the model.  Use na.action=na.exclude when fitting the
model instead of the default na.action=na.omit to make the prediction
vector line up with the input data instead of lining up with the input data
after the NA-rows have been dropped.

E.g.,
[1] 9
[1] 10
1          2          3          4          5          6
 7          8          9         10
-0.2041631  2.4602537         NA  5.1246704  5.9824210  6.6832543
 7.2758004  7.7890872  8.2418382  8.6468378


Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Jun 12, 2017 at 1:32 PM, Manqing Liu <hopkins0727 at gmail.com> wrote:

            

  
  
#
First, you should read the Posting Guide. Then you should read the help page for ?predict. 

Only then should  you write a follow-up email (in plain text) with code that constructs a simple example using whatever method was used to construct this `pr` variable and  provide enough information to support a sensible answer.
David Winsemius
Alameda, CA, USA