[R] Sample Weights

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Mon Jul 27 09:37:38 CEST 2015


R is a computing tool, and each package has implemented algorithms that have history and books and papers that allow those algorithms to be used in a variety if computing environments... from Fortran to Excel to Java to ... R, and probably beyond.

>From your description I am going to hazard a guess that perhaps you are considering regression, where the ranges of some variables may be much smaller than others, and yes, among the many types of regression there are many that accept weights... constant values used to scale each "column" of data so that they all have similar ranges. You might be able to get along just fine with the lm function from base R [1], or you might need something more specialized as [2] might discuss. Or you may have something else in mind, but only you can clarify what that might be.

It may be wise to do a bit of reading so you know which algorithms you want to apply, and then give us a reproducible, small example of what you have and what you want to get out of this analysis. To do that, you will really need to read and follow the advice in [3].

[1] type "?lm" at the R prompt to get details about that function. If that is too terse, get a text book.
[2] https://cran.r-project.org/web/views/Multivariate.html
[3] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example 
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On July 26, 2015 11:37:31 PM PDT, Amelia Marsh <amelia_marsh08 at yahoo.com> wrote:
>Dear Sir,
>
>I do appreciate your views. Yes even I was also aware about the non
>clarity in the question. Actaully, I have a large data having lots of
>data of low magnitude and few of very high magnitude. In order to
>analyse the same, some very senior person in the office suggested me to
>assign weights to these obervations.
>
>Problem is this senior person is on office tour travelling into
>Australia and unfortutely I can't even think of reverting to him owing
>to his seniority. I tried to find through some R libraries if I can get
>something about sample weights. 
>
>But as you have pointed out, yes my question is too vague and feel
>really sorry about the same. And I have recently started with R
>language hence I am trying to learn some basics about R. Thanks for
>pointing the difference between data.frame and vector.
>
>
>Thanks again for your response.
>
>Regards
>
>Amelia
>
>_____________________________________________________________________________________________
>
>
>
>On Monday, 27 July 2015 11:49 AM, Jeff Newmiller
><jdnewmil at dcn.davis.CA.us> wrote:
>If you have a clear idea what meaning those weights have (?) in the
>context of a specific calculation (?), and you know what the weights
>are (?), then it is usually trivially easy to do in R. However,  your
>question is vague on all of those points, so offering you a solution
>seems like an invitation for you to mis-use any particular solution
>offered. Please try to clarify what you are doing that "weights" will
>help with, and yes, there may just be a weights argument to the
>function that does that analysis that we can point you to.
>
>You also are unclear what the difference between a data frame and a
>vector is... if it helps, a data frame is a list of vectors (typically
>referred to as "columns") all with the same length...  your "mydat" is
>a vector, not a data frame.
>---------------------------------------------------------------------------
>Jeff Newmiller                        The     .....       .....  Go
>Live...
>DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live
>Go...
>                                     Live:   OO#.. Dead: OO#..  Playing
>Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
>/Software/Embedded Controllers)               .OO#.       .OO#. 
>rocks...1k
>---------------------------------------------------------------------------
>
>Sent from my phone. Please excuse my brevity.
>
>
>On July 26, 2015 11:00:54 PM PDT, Amelia Marsh via R-help
><r-help at r-project.org> wrote:
>>Dear R Forum
>>
>>I have a data.frame as
>>
>>
>>mydat =
>>c(6,6,5,6,4,6,8,4,6,6,6,3,4,6,5,7,7,4,3,5,5,5,3,6,7,4,4,7,4,3,4,6,4,6,5,4,4,7,6,8,5,6,5,5,8,2,3,5,7,5)
>>
>>Is there any library or way in R to allocate weights to these values?
>>Actually I am having a large data, but for illustrative purpose, have
>>considered just a small part of the same. 
>>
>>Regards
>>
>>Amelia
>>
>>______________________________________________
>>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>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.



More information about the R-help mailing list