Displaying 12 results from an estimated 12 matches for "nonmissing".
2007 Feb 16
2
missing -> nonmissing levels
Hi,
I expect this is simple but haven’t found an answer looking on the
archives...
I want to convert ‘NA’ (missing) to particular levels (nonmissing) in factor
vectors.
e.g. I know
> X <- c(1, 2, 3)
> summary(X)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.0 1.5 2.0 2.0 2.5 3.0
> X <- as.factor(X)
> summary(X)
1 2 3
1 1 1
> levels(X)
[1] "1" "2" "3"...
2003 Nov 12
1
Plotting lm() attributes
...linear model
> model.1 ~ lm(v1 ~ ..., data=myframe)
and v2 is some other column of myframe typically not in the model. You
will often want to try
> plot(v2, model.1$residuals)
but this will fail if there are NAs in the response v1 as
model.1$residuals has length equal to the number of nonmissing values in
v1. I suppose
> plot(v2[!is.na(v1)], model.1$residuals)
does the job, but it seems irritating that model.1$residuals, does not
have length agreeing with the number of rows in the data frame. It would
be even more irritating for model.1$fitted.values, where the removed
elements...
2009 Oct 21
3
Missing data and LME models and diagnostic plots
Hello
Running R2.9.2 on Windows XP
I am puzzled by the performance of LME in situations where there are missing data. As I understand it, one of the strengths of this sort of model is how well it deals with missing data, yet lme requires nonmissing data.
Thus,
m1.mod1 <- lme(fixed = math_1 ~ I(year-2007.5)*TFC_,
data = long,
random = ~I(year-2007.5)|schoolnum)
causes an error in na.fail.default, but adding na.action = "na.omit" makes a model with no errors. However, if I create that model, i...
2011 Dec 26
4
Summary tables of large datasets including character and numerical variables
Hello !
I am attempting to switch from being a long time SAS user to R, and would
really appreciate a bit of help ! The first thing I do in getting a large
dataset (thousands of obervations and hundreds of variables) is to run a SAS
command PROC CONTENTS VARNUM command - this provides me a table with the
name of each variable, its type and length; then I run a PROC MEANS - for
numerical
2005 Jul 25
0
lda: scaling to 'disctiminant function'
...lda is the
R-function I want. I have done this in SPSS using the code (is it 'S'
code?)...
"DISCRIMINANT /GROUPS=group(1 3) /VARIABLES=agr min man ps con ser fin
sps tc /ANALYSIS ALL /PRIORS EQUAL /STATISTICS=MEAN STDDEV UNIVF COEFF
RAW COV TABLE /PLOT=COMBINED MAP /CLASSIFY=NONMISSING POOLED "
In R I express this as...
library("MASS") # For lda
library("foreign")
EW <- read.spss("eurowork.sav")
Ind <- cbind(EW$AGR, EW$MIN, EW$MAN, EW$PS, EW$CON, EW$SER, EW$FIN,
EW$SPS, EW$TC)
Dep <- EW$GROUP
LDA <- lda(Dep ~ Ind, prior=c(1,1,1)/3)...
2011 Jun 16
1
Replacing values without looping
I got an array similar to the one below, and want to replace all NAs with the
previous value.
99 8.2 b
NA 8.3 x
NA 7.9 x
98 8.1 b
NA 7.7 x
99 9.3 b
...
i.e. the first two NAs should be replaced to 99, whereas the last one should
be 98.
I would like to apply a function to reach row, checking if the value in col
1 is NA, and if it is, set the value to the previous row's col 1 value.
1997 Aug 21
1
R-alpha: another ctest question
I have the following problem. Consider a `classical' test which works
for k .ge. 2 samples. Possible interfaces are e.g.
xxx.test(x, g) x ... all data, g ... corresponding groups
xxx.test(x1, ..., xk)
xxx.test(list(x1, ..., xk))
etc etc.
Clearly, the first and the second one are nice, but cannot be combined
without making `g' (i.e., `group') a named argument.
Hence, in
2007 Jan 03
1
na.action and simultaneous regressions
Hi.
I am running regressions of several dependent variables using the same set
of independent variables. The independent variable values are complete, but
each dependent variable has some missing values for some observations; by
default, lm(y1~x) will carry out the regressions using only the observations
without missing values of y1. If I do lm(cbind(y1,y2)~x), the default will
be to use
2005 Nov 27
1
Question on KalmanSmooth
I am trying to use KalmanSmooth to smooth a time series
fitted by arima (and with missing values), but the $smooth component
of the output baffles me. Look at the following example:
testts <- arima.sim(list(ar=0.9),n=100)
testts[6:14] <- NA
testmod <- arima(testts, c(1,0,0))
testsmooth <- KalmanSmooth(testts, testmod$model)
par(mfrow=c(2,1))
plot(testsmooth$smooth,
2011 May 04
3
SAPPLY function XXXX
Hello everyone,
I am attempting to write a function to count the number of non-missing
values of each column in a data frame using the sapply function. I have the
following code which is receiving the error message below.
> n.valid<-sapply(data1,sum(!is.na))
Error in !is.na : invalid argument type
Ultimately, I would like for this to be 1 conponent in a larger function
that will produce
2011 Jun 17
4
combining strings
Dear R People:
Suppose I have the following two character vectors:
xf
[1] "W" NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
> xg
[1] NA "k" "h" NA "g" "r" "j" NA "v" "d" NA "v" NA "z" "r" "r" "i"
>
I want to end up with
"W"
2012 Aug 10
2
Simple question about formulae in R!?
Good morning reader,
I have encountered a, probably, simple issue with respect to the *formulae* of
a *regression model* I want to use in my research. I’m researching
alliances as part of my study Business Economics (focus Strategy) at the
Vrije Universiteit in Amsterdam. In the research model I use a moderating
variable, I’m looking for confirmation or help on the formulation of the
model.