[R] Least Squares Method

Joshua Wiley jwiley.psych at gmail.com
Tue Apr 26 23:56:24 CEST 2011

Hi Vana,

I am not sure what package gls() is in off hand, but many model
fitting functions have a subset argument.  If not, supposing your data
is in "dat", and the variable with the zeros in it that are concerning
you is "X", then something like:

newdat <- dat[dat[, "X"] != 0, ]

and now fit gls() on "newdat" instead of "dat".



P.S. Throwing out data (even zeros) is typically not a good choice and
leads to biased results.  Before using this for any serious research,
I would strongly recommend consulting with a local statistician or
some other individual who can work with you to understand your data,
where those zeros come from and what they might mean, come up with
reasonable assumptions, and use modelling techniques that can include
the information encoded in those zeros rather than simply throwing
them out.

On Tue, Apr 26, 2011 at 1:43 PM, Vana <vana at auth.gr> wrote:
> Hi everyone,
> I am running the 'gls' command (least squares method) for a number of data
> out of which many are zeros. I strongly believe that the output is wrong and
> I think that this is due to the large number of zero values included in my
> dataset.
> I would like to ask if there is a command that would allow me to run the gls
> command disregarding all the zero values?
> Thank you in advance...
> --
> View this message in context: http://r.789695.n4.nabble.com/Least-Squares-Method-tp3476485p3476485.html
> Sent from the R help mailing list archive at Nabble.com.
> ______________________________________________
> 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.

Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles

More information about the R-help mailing list