[R] Genrating Ordinal Responses in R

arnabkm2007 maity at math.niu.edu
Sat Feb 14 23:06:00 CET 2015


Thank you very much JS Huang. It helps.

Thanks & Regards,
Arnab



Arnab Kumar Maity
Graduate Teaching Assistant
Division of Statistics
Northern Illinois University
DeKalb, IL 60115
Email: maity at math.niu.edu
Ph:     779-777-3428

On Fri, Feb 13, 2015 at 5:03 PM, JS Huang [via R] <
ml-node+s789695n4703244h14 at n4.nabble.com> wrote:

> Hi,
>
>   Here assume there are four elements in the ordinal set y and take a
> random sample of size 10 according to the cumulative distribution given, or
> probability distribution p below.
>
>
> > y <- c(levels = c("First", "Second", "Third", "Fourth"))
> > y
>  levels1  levels2  levels3  levels4
>  "First" "Second"  "Third" "Fourth"
> > (x <- c(1/9, 1/4, 3/5, 1))
> [1] 0.1111111 0.2500000 0.6000000 1.0000000
> > p <- c(x[1], x[2]-x[1], x[3]-x[2], x[4]-x[3])
> > p
> [1] 0.1111111 0.1388889 0.3500000 0.4000000
> > sample(y, 10, replace=TRUE, prob=p)
>  levels2  levels4  levels4  levels3  levels1  levels3  levels4  levels2
>  levels4  levels3
> "Second" "Fourth" "Fourth"  "Third"  "First"  "Third" "Fourth" "Second"
> "Fourth"  "Third"
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://r.789695.n4.nabble.com/Genrating-Ordinal-Responses-in-R-tp4703159p4703244.html
>  To unsubscribe from Genrating Ordinal Responses in R, click here
> <http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4703159&code=bWFpdHlAbWF0aC5uaXUuZWR1fDQ3MDMxNTl8MTMwNTA3NDMzMA==>
> .
> NAML
> <http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://r.789695.n4.nabble.com/Genrating-Ordinal-Responses-in-R-tp4703159p4703274.html
Sent from the R help mailing list archive at Nabble.com.
	[[alternative HTML version deleted]]



More information about the R-help mailing list