[Rsiena-help] selecting certain actors

Ruth M. Ripley ruth at stats.ox.ac.uk
Mon Mar 8 16:01:43 CET 2010


Dear Maarten,

Do you want to change the others to 0? Or exclude them?  To do the former:

net[!net %in% c(1,2,3,4)] <- 0

To exclude them the easiest way is to make them missing and use na.omit:

net <- na.omit(net)

You will need to alter the real missings to something else, though eg

net[is.na(net)] <- 999

then do the other two lines and then

net[net==999] <- NA

Regards,

Ruth
--
Ruth M. Ripley,                         Email:ruth at stats.ox.ac.uk
Dept. of Statistics,                    http://www.stats.ox.ac.uk/~ruth/
University of Oxford,                   Tel:   01865 282851
1 South Parks Road, Oxford OX1 3TG, UK  Fax:   01865 272595


On Mon, 8 Mar 2010, Maarten Van Zalk wrote:

> Dear Ruth,
>
> a follow-up question on using specific actors: is it possible to select a
> range of scores? so for example the scores 1 until 4?
>
> Thanks for your help yet again!
>
> Maarten
>
> On Mon, Feb 15, 2010 at 12:59 PM, Ruth M. Ripley <ruth at stats.ox.ac.uk>wrote:
>
> > Dear Maarten,
> >
> > There are no special facilities: you would need to extract the subsets of
> > the matrices yourself before creating the Siena network object. Using the
> > command line, after reading in some data:
> >
> > friend.data.w1 <- as.matrix(read.table("s50-network1.dat"))
> > friend.data.w2 <- as.matrix(read.table("s50-network2.dat"))
> > drink <- as.matrix(read.table("s50-alcohol.dat"))
> > smoke <- as.matrix(read.table("s50-smoke.dat"))
> >
> > To select the actors with the first column of smoke equal to 1, say,
> >
> > use <- smoke[, 1] == 1
> >
> > friendship <- sienaNet(array(c(friend.data.w1[use, use],
> >       friend.data.w2[use, use]), dim=c(38, 38, 2)))
> >
> > alcohol <- sienaNet(drink[use, ], type="behavior")
> >
> > To do this via the gui, you would need to do the subsetting outside R.
> >
> > Regards,
> >
> > Ruth
> >
> > PS I have copied this message to the rsiena-help mailing list. I see two
> > benefits to using the lists: others might find the information useful too,
> > and if I am busy someone else might be able to help!
> > --
> > Ruth M. Ripley,                         Email:ruth at stats.ox.ac.uk<Email%3Aruth at stats.ox.ac.uk>
> > Dept. of Statistics,                    http://www.stats.ox.ac.uk/~ruth/
> > University of Oxford,                   Tel:   01865 282851
> > 1 South Parks Road, Oxford OX1 3TG, UK  Fax:   01865 272595
> >
> >
> > On Mon, 15 Feb 2010, Maarten Van Zalk wrote:
> >
> > > Dear Ruth,
> > >
> > > Is it possible in RSiena to select certain actors for the analysis? So
> > > if you have a variable X you want to use to select individuals (for
> > > example, all individuals with a score of 1), Can you select only these
> > > individuals?
> > >
> > > Thanks for your help!
> > >
> > > Kind regards,
> > >
> > > Maarten Van Zalk
> > >
> >
> >
>



More information about the Rsiena-help mailing list