[Rsiena-help] Selecting actors based on changing covariate

Ruth M. Ripley ruth at stats.ox.ac.uk
Tue Mar 9 20:46:43 CET 2010


Dear Maarten,

Sorry, this was my fault: if you have missing values, sum needs to be told
to exclude them, and I forgot to tell you this. After a while you see the
NA and react immediately: Oh dear, I forgot "na.rm=TRUE" e.g.

sum(use, na.rm=TRUE)

to select a range, use %in%:

use <- shy %in% 1:4

%in% is kind in that it does not insist you remove missing values. The
alternative

use <- shy > 0 & shy < 5

would need

use <- is.na(shy) & shy > 0 & shy < 5

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 Tue, 9 Mar 2010, Maarten Van Zalk wrote:

> Dear Ruth,
>
> now that all versions are up to date (working in version 1.0.10), I
> have a follow-up question on selecting actors based on a changing
> actor covariate:
>
> I am trying to select actors on a range of scores on the variable
> shyness ("shy"), but when I check how many are selected with this use
> I get "NA" (thus missing):
>
>
>
>
>  > library(RSiena)
> Loading required package: xtable
>  >    library(snow)
>  >    library(rlecuyer)
>  >   setwd('/Users/maartenselfhout/Desktop/justin')
>  >   net.w1 <- as.matrix(read.table("W3SIENA.dat"))
>  >    net.w2 <- as.matrix(read.table("W4SIENA.dat"))
>  >    net.w3 <- as.matrix(read.table("W5SIENA.dat"))
>  >    rad <- as.matrix(read.table("radical.dat"))
>  >   shy <- as.matrix(read.table("shy.dat"))
>  > rad[rad %in% c(99)] <- NA
>  >   shy[shy %in% c(99)] <- NA
>  >  net.w1[net.w1 %in% c(6,9)] <- NA
>  >    net.w2[net.w2 %in% c(6,9)] <- NA
>  >    net.w3[net.w3 %in% c(6,9)] <- NA
>  > use <- shy[, 1] == 4
>  > sum(use)
> [1] NA
>  > use <- shy[, 2] == 4
>  > sum(use)
> [1] NA
>  > use <- shy[, 1] == 1
>  > sum(use)
> [1] NA
>  > use <- rad[, 1] == 1
>  > sum(use)
> [1] 14
>  > use <- shy[, 3] == 1,2,3
> Error: unexpected ',' in "use <- shy[, 3] == 1,"
>  > use <- shy[, 1] == 1-3
>  > sum(use)
> [1] NA
>  >
>
> However, in the files there are more than 100 actors with these
> scores, so I must be specifying something wrong...Do you have to
> recode missings? in which way and how (is this similar to how you did
> this for networks)?
>
> Best regards,
>
> Maarten
>
>
>
> On Mar 9, 2010, at 19:30 , Ruth M. Ripley wrote:
>
> > Dear Maarten,
> >
> > R needs to be updated outside R. You can just download and install
> > the new
> > version (just double click on the installer, or remove the old one
> > first,
> > by removing to Trash the application R-app in Appplications and the R
> > framework in /Library/Frameworks.
> >
> > There are some more details about it in the R for MaC FAQ, but I am
> > not
> > sure what they mean(I know rather little about Macs!), so just let
> > me know
> > if you have problems and I'll try to help. I don't have an old
> > version of
> > R on my Mac to practise on, but could probably install one if I need
> > to!
> >
> > 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 Tue, 9 Mar 2010, Maarten Van Zalk wrote:
> >
> >> Dear Ruth,
> >>
> >> I keep getting errors when I try to install on my mac.
> >>
> >> My current version is 1.0.5. I have all administration rights as this
> >> is my own bought computer, so this is not the problem.
> >>
> >>
> >> This what I get when I try to update within R:
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/bin/macosx/universal/contrib/2.9/VR_7.2-49.tgz'
> >> Content type 'application/x-gzip' length 985090 bytes (962 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 962 Kb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/bin/macosx/universal/contrib/2.9/Matrix_0.999375-31.tgz'
> >> Content type 'application/x-gzip' length 2826531 bytes (2.7 Mb)
> >> opened URL
> >> ==================================================
> >> downloaded 2.7 Mb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/bin/macosx/universal/contrib/2.9/boot_1.2-41.tgz'
> >> Content type 'application/x-gzip' length 448262 bytes (437 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 437 Kb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/bin/macosx/universal/contrib/2.9/class_7.3-1.tgz'
> >> Content type 'application/x-gzip' length 51893 bytes (50 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 50 Kb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/bin/macosx/universal/contrib/2.9/cluster_1.12.1.tgz'
> >> Content type 'application/x-gzip' length 333414 bytes (325 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 325 Kb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/bin/macosx/universal/contrib/2.9/foreign_0.8-38.tgz'
> >> Content type 'application/x-gzip' length 204134 bytes (199 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 199 Kb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/bin/macosx/universal/contrib/2.9/lattice_0.17-26.tgz'
> >> Content type 'application/x-gzip' length 610668 bytes (596 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 596 Kb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/bin/macosx/universal/contrib/2.9/mgcv_1.5-6.tgz'
> >> Content type 'application/x-gzip' length 817083 bytes (797 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 797 Kb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/bin/macosx/universal/contrib/2.9/nlme_3.1-96.tgz'
> >> Content type 'application/x-gzip' length 1249422 bytes (1.2 Mb)
> >> opened URL
> >> ==================================================
> >> downloaded 1.2 Mb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/bin/macosx/universal/contrib/2.9/nnet_7.3-1.tgz'
> >> Content type 'application/x-gzip' length 61916 bytes (60 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 60 Kb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/bin/macosx/universal/contrib/2.9/spatial_7.3-1.tgz'
> >> Content type 'application/x-gzip' length 84723 bytes (82 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 82 Kb
> >>
> >>
> >> The downloaded packages are in
> >> 	/var/folders/fp/fp69YKRoHIqhZmwhT4VqxE+++TI/-Tmp-//RtmpBsgWSv/
> >> downloaded_packages
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/src/contrib/RSiena_1.0.9.tar.gz'
> >> Content type 'application/x-gzip' length 848088 bytes (828 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 828 Kb
> >>
> >> During startup - Warning messages:
> >> 1: Setting LC_CTYPE failed, using "C"
> >> 2: Setting LC_TIME failed, using "C"
> >> 3: Setting LC_MESSAGES failed, using "C"
> >> * Installing *source* package 'RSiena' ...
> >> ** libs
> >> ** arch - i386
> >> sh: make: command not found
> >> ERROR: compilation failed for package 'RSiena'
> >> * Removing '/Library/Frameworks/R.framework/Versions/2.9/Resources/
> >> library/RSiena'
> >> * Restoring previous '/Library/Frameworks/R.framework/Versions/2.9/
> >> Resources/library/RSiena'
> >>
> >> The downloaded packages are in
> >> 	'/private/var/folders/fp/fp69YKRoHIqhZmwhT4VqxE+++TI/-Tmp-/
> >> RtmpBsgWSv/
> >> downloaded_packages'
> >> also installing the dependency 'xtable'
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/src/contrib/xtable_1.5-6.tar.gz'
> >> Content type 'application/x-gzip' length 142697 bytes (139 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 139 Kb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/src/contrib/Matrix_0.999375-37.tar.gz'
> >> Content type 'application/x-gzip' length 2587244 bytes (2.5 Mb)
> >> opened URL
> >> ==================================================
> >> downloaded 2.5 Mb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/src/contrib/RSiena_1.0.9.tar.gz'
> >> Content type 'application/x-gzip' length 848088 bytes (828 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 828 Kb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/src/contrib/foreign_0.8-39.tar.gz'
> >> Content type 'application/x-gzip' length 330828 bytes (323 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 323 Kb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/src/contrib/mgcv_1.6-1.tar.gz'
> >> Content type 'application/x-gzip' length 395943 bytes (386 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 386 Kb
> >>
> >> trying URL 'http://ftp.sunet.se/pub/lang/CRAN/src/contrib/survival_2.35-8.tar.gz'
> >> Content type 'application/x-gzip' length 672616 bytes (656 Kb)
> >> opened URL
> >> ==================================================
> >> downloaded 656 Kb
> >>
> >> During startup - Warning messages:
> >> 1: Setting LC_CTYPE failed, using "C"
> >> 2: Setting LC_TIME failed, using "C"
> >> 3: Setting LC_MESSAGES failed, using "C"
> >> * Installing *source* package 'xtable' ...
> >> ** R
> >> ** data
> >> ** inst
> >> ** preparing package for lazy loading
> >> ** help
> >> *** installing help indices
> >> perl: warning: Setting locale failed.
> >> perl: warning: Please check that your locale settings:
> >> 	LC_ALL = (unset),
> >> 	LC_COLLATE = "C",
> >> 	LANG = "en_SE.UTF-8"
> >>     are supported and installed on your system.
> >> perl: warning: Falling back to the standard locale ("C").
> >>>>> Building/Updating help pages for package 'xtable'
> >>      Formats: text html latex example
> >>   print.xtable                      text    html    latex
> >>   string                            text    html    latex
> >>   table.attributes                  text    html    latex
> >>   tli                               text    html    latex
> >>   xtable                            text    html    latex   example
> >> ** building package indices ...
> >> * DONE (xtable)
> >> During startup - Warning messages:
> >> 1: Setting LC_CTYPE failed, using "C"
> >> 2: Setting LC_TIME failed, using "C"
> >> 3: Setting LC_MESSAGES failed, using "C"
> >> * Installing *source* package 'Matrix' ...
> >> ** libs
> >> ** arch - i386
> >> sh: make: command not found
> >> ERROR: compilation failed for package 'Matrix'
> >> * Removing '/Library/Frameworks/R.framework/Versions/2.9/Resources/
> >> library/Matrix'
> >> * Restoring previous '/Library/Frameworks/R.framework/Versions/2.9/
> >> Resources/library/Matrix'
> >> During startup - Warning messages:
> >> 1: Setting LC_CTYPE failed, using "C"
> >> 2: Setting LC_TIME failed, using "C"
> >> 3: Setting LC_MESSAGES failed, using "C"
> >> * Installing *source* package 'foreign' ...
> >> /Library/Frameworks/R.framework/Resources/bin/config: line 143: make:
> >> command not found
> >> /Library/Frameworks/R.framework/Resources/bin/config: line 144: make:
> >> command not found
> >> /Library/Frameworks/R.framework/Resources/bin/config: line 220: make:
> >> command not found
> >> /Library/Frameworks/R.framework/Resources/bin/config: line 143: make:
> >> command not found
> >> checking for gcc... no
> >> checking for cc... no
> >> checking for cc... no
> >> checking for cl... no
> >> /Library/Frameworks/R.framework/Resources/bin/config: line 144: make:
> >> command not found
> >> /Library/Frameworks/R.framework/Resources/bin/config: line 220: make:
> >> command not found
> >> configure: error: no acceptable C compiler found in $PATH
> >> See `config.log' for more details.
> >> ERROR: configuration failed for package 'foreign'
> >> * Removing '/Library/Frameworks/R.framework/Versions/2.9/Resources/
> >> library/foreign'
> >> * Restoring previous '/Library/Frameworks/R.framework/Versions/2.9/
> >> Resources/library/foreign'
> >> During startup - Warning messages:
> >> 1: Setting LC_CTYPE failed, using "C"
> >> 2: Setting LC_TIME failed, using "C"
> >> 3: Setting LC_MESSAGES failed, using "C"
> >> * Installing *source* package 'survival' ...
> >> ** libs
> >> ** arch - i386
> >> sh: make: command not found
> >> ERROR: compilation failed for package 'survival'
> >> * Removing '/Library/Frameworks/R.framework/Versions/2.9/Resources/
> >> library/survival'
> >> * Restoring previous '/Library/Frameworks/R.framework/Versions/2.9/
> >> Resources/library/survival'
> >> During startup - Warning messages:
> >> 1: Setting LC_CTYPE failed, using "C"
> >> 2: Setting LC_TIME failed, using "C"
> >> 3: Setting LC_MESSAGES failed, using "C"
> >> * Installing *source* package 'RSiena' ...
> >> ** libs
> >> ** arch - i386
> >> sh: make: command not found
> >> ERROR: compilation failed for package 'RSiena'
> >> * Removing '/Library/Frameworks/R.framework/Versions/2.9/Resources/
> >> library/RSiena'
> >> * Restoring previous '/Library/Frameworks/R.framework/Versions/2.9/
> >> Resources/library/RSiena'
> >> During startup - Warning messages:
> >> 1: Setting LC_CTYPE failed, using "C"
> >> 2: Setting LC_TIME failed, using "C"
> >> 3: Setting LC_MESSAGES failed, using "C"
> >> * Installing *source* package 'mgcv' ...
> >> ** libs
> >> ** arch - i386
> >> sh: make: command not found
> >> ERROR: compilation failed for package 'mgcv'
> >> * Removing '/Library/Frameworks/R.framework/Versions/2.9/Resources/
> >> library/mgcv'
> >> * Restoring previous '/Library/Frameworks/R.framework/Versions/2.9/
> >> Resources/library/mgcv'
> >>
> >> The downloaded packages are in
> >> 	'/private/var/folders/fp/fp69YKRoHIqhZmwhT4VqxE+++TI/-Tmp-/
> >> RtmpBsgWSv/
> >> downloaded_packages'
> >>>
> >>
> >>
> >> As you can see, I get some errors referring to the C drive (which
> >> does
> >> not exist on the MAC). Does anytone else have a mac and has this
> >> problem?
> >>
> >> Kind regards,
> >>
> >> Maarten
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Mar 8, 2010, at 17:15 , Ruth M. Ripley wrote:
> >>
> >>> Dear Maarten,
> >>>
> >>> Are you only wanting to include 14 actors?
> >>>
> >>> I am not sure what the problem is. If you want to save the workspace
> >>> and send me a copy, I will look at it. (There is an option on the
> >>> menu to save workspaces.) And confirm which version of R and RSiena
> >>> you are using.
> >>>
> >>> 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,
> >>>>
> >>>> I tried the 'sum' command, and now run into the following problem:
> >>>>
> >>>>
> >>>>> sum(use)
> >>>> [1] 14
> >>>>> friendship <- sienaNet(array(c(net.w1[use, use], net.w2[use,
> >>>>> use],net.w3[use, use]),dim=c(sum(use), sum(use), 3)))
> >>>>> mydata <- sienaDataCreate(friendship,shy,self,depr)
> >>>>> myeff <- getEffects(mydata)
> >>>> Error in rep(shortnames, times = (1 + as.numeric(endowment))) :
> >>>> invalid 'times' argument
> >>>>
> >>>> Is there something I am missing?
> >>>>
> >>>> Kind regards,
> >>>>
> >>>> Maarten
> >>>>
> >>>>
> >>>> On Mar 8, 2010, at 15:55 , Ruth M. Ripley wrote:
> >>>>
> >>>>> Dear Maarten,
> >>>>> If the 796 is all the actors, you need to reduce it to the number
> >>>>> you
> >>>>> actually include. This can be found as sum(use):
> >>>>> friendship <- sienaNet(array(c(net.w1[use, use], net.w2[use, use],
> >>>>>> net.w3[use, use]),dim=c(sum(use), sum(use), 3)))
> >>>>> 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,
> >>>>>> An additional question on selecting specific actors:
> >>>>>> As I run the following syntax, I get the error:
> >>>>>>> library(RSiena)
> >>>>>>> library(snow)
> >>>>>>> library(rlecuyer)
> >>>>>>> setwd('/Users/maartenselfhout/Desktop/CrowdStudy/justin')
> >>>>>>> net.w1 <- as.matrix(read.table("W3SIENA.dat"))
> >>>>>>> net.w2 <- as.matrix(read.table("W4SIENA.dat"))
> >>>>>>> net.w3 <- as.matrix(read.table("W5SIENA.dat"))
> >>>>>>> rad <- as.matrix(read.table("radical.dat"))
> >>>>>>> depr <- as.matrix(read.table("depress.dat"))
> >>>>>>> self <- as.matrix(read.table("selfesteem.dat"))
> >>>>>>> shy <- as.matrix(read.table("shy.dat"))
> >>>>>>> net.w1[net.w1 %in% c(6,9)] <- NA
> >>>>>>> net.w2[net.w2 %in% c(6,9)] <- NA
> >>>>>>> net.w3[net.w3 %in% c(6,9)] <- NA
> >>>>>>> rad[rad %in% c(99)] <- NA
> >>>>>>> depr[depr %in% c(99)] <- NA
> >>>>>>> self[self %in% c(99)] <- NA
> >>>>>>> shy[shy %in% c(99)] <- NA
> >>>>>>> use <- rad[, 1] == 1
> >>>>>>> friendship <- sienaNet(array(c(net.w1[use, use], net.w2[use,
> >>>>>>> use],
> >>>>>> net.w3[use, use]),dim=c(796, 796, 3)))
> >>>>>>> shy <- sienaNet(shy[use, ], type='behavior')
> >>>>>>> depr <- varCovar(val = depr[use, ])
> >>>>>>> self <- varCovar(val = self2[use, ])
> >>>>>> Error in varCovar(val = self2[use, ]) : object 'self2' not found
> >>>>>>> self <- varCovar(val = self[use, ])
> >>>>>>> mymodel <- model.create(useStdInits = TRUE, projname = 'crowd')
> >>>>>>> mydata <- sienaDataCreate(friendship,depr,self,shy,rad)
> >>>>>> Error: invalid object in sienaDataCreate matrix
> >>>>>>> mydata <- sienaDataCreate(friendship,depr,self,shy)
> >>>>>>> myeff <- getEffects(mydata)
> >>>>>> Error in storage.mode(test) <- "logical" : subscript out of
> >>>>>> bounds
> >>>>>> Do you have any idea why this error arises?
> >>>>>> It does NOT arise when I run the syntax without the 'use' command
> >>>>>> Thanks!
> >>>>>> Kind regards,
> >>>>>> Maarten Selfhout-Van Zalk
> >>>>>> On Feb 15, 2010, at 12:59 , Ruth M. Ripley 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
> >>>>>>> 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