[R] fminsearch usage

2013-10-02 Thread Edward Patzelt
R Help - I'm attempting to use fminsearch and it continues to give me errors. I have a normal Rescorla Wagner function that has 2 parameters and returns total error. for some reason fminsearch keeps saying the type of errors below, I've put the function and data after it using dput > sol <- fmins

[R] Constructing a matrix of outputs from loop

2013-07-08 Thread Edward Patzelt
R - I would like to construct a matrix from the output of a loop that has 2 values it varies over the course of the loop creating a 20x20 matrix of output values: ap = logspace(-3, 0, 20) am = logspace(-3, .7, 20) for (ap in apList) { for (am in amList) { output = func(ap, am) } }

[R] Changing Order of Factor Levels in Mixed Model (nlme)

2013-05-14 Thread Edward Patzelt
R Help - Why is that in the results below, changing the order of the factor (trialType2: levels - DD, SD, DS, SS) changes the estimates in the fixed effects tests? > tmp.dat4$trialType2 <- sort(tmp.dat4$trialType, decreasing = TRUE) > mod2c <- lme(proportion.down ~ trialType2, data = tmp.dat4, ra

[R] Aggregate Table Data into Cell Frequencies

2012-10-31 Thread Edward Patzelt
R-help - I have this set of aggregated tables (sample data below via dput()). And I would like to have delayValue as the column variables with the "temp" (temp1, temp2, temp3) values as the row variables. However I would like to have the temp variables *aggregated into single rows* so that I hav

[R] Axis Breaks with ggplot2

2012-10-19 Thread Edward Patzelt
R-help - I'm trying to create axis breaks similar to this : http://www.r-bloggers.com/wp-content/uploads/2010/08/bar-chart-natural-axis-split1.png . Is there a way to do this in R? Here's my code thus far: structure(list(condition = structure(c(2L, 1L, 3L), .Label = c("con", "exp", "unedit"), c

[R] Softmax Action Selection

2012-06-20 Thread Edward Patzelt
R Community - I'm attempting to apply a softmax action selection to a probability generated by a hidden Markov model. I'm having difficulties in how to apply the softmax temperature parameter (beta). Here is my code thus far. I'm thinking the sigmoid function will work but I need this function

Re: [R] Running Total

2012-03-05 Thread Edward Patzelt
1 5 > [7,] 1 6 > [8,] 1 7 > [9,] 0 7 > [10,] 1 8 > [11,] 0 8 > [12,] 1 9 > [13,] 1 10 > [14,] 1 11 > [15,] 1 12 > [16,] 1 13 > [17,] 0 13 > > > On Mon, Mar 5, 2012 at 1:51 PM, Edward Patzelt wrote: > > I'm am trying

[R] Running Total

2012-03-05 Thread Edward Patzelt
I'm am trying to create a vector that has a running total that adds each time a 1 occurs. here's the code and data c(1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L,

[R] Cubic Gradient Descent Package

2011-11-16 Thread Edward Patzelt
R - Does anyone know of a cubic gradient descent package? I found grad.desc() but that only allows for a 2d function. I have 3 free parameters and thus am looking for a 3d function. Thank you, -- Edward H. Patzelt Research Assistant – TRiCAM Lab University of Minnesota – Psychology/Psychiatr

Re: [R] Counting Elements Conditionally

2011-08-22 Thread Edward Patzelt
A, NA, 3, NA,NA, NA, 2) ? > > Jean > > Edward Patzelt wrote on 08/22/2011 03:58:38 PM: > > > [image removed] > > > > Re: [R] Counting Elements Conditionally > > > > Edward Patzelt > > > > to: > > > > Jean V Adams >

Re: [R] Counting Elements Conditionally

2011-08-22 Thread Edward Patzelt
after it sees the first occurrence of 0 in FF following a transition, I want it to ignore all further elements until the next transition. On Mon, Aug 22, 2011 at 3:58 PM, Edward Patzelt wrote: > Awesome, this is close, couple changes. Below is full data set for 1 > person. I want the c

Re: [R] Counting Elements Conditionally

2011-08-22 Thread Edward Patzelt
)), .Names = c("Rev", "FF", "bin"), row.names = c(NA, -125L), class = "data.frame") On Mon, Aug 22, 2011 at 3:57 PM, Jean V Adams wrote: > > > Re: [R] Counting Elements Conditionally > > Jean V Adams > > to: > > Edward Patzelt &g

[R] Counting Elements Conditionally

2011-08-22 Thread Edward Patzelt
R - I have 3 variables with data below. Variable "Rev" is a vector that changes from 1 to 2, 2 to 3, etc Variable "FF" is a binary variable with 1's and 0's. Variable "bin" is a different binary variable with 1's and 0's. I want to calculate the number of elements: 1. Starting with the f

[R] Indexing Permutation Values

2011-08-15 Thread Edward Patzelt
R-help - This code iterates over a function with 2 free parameters to find a list of values (which are the number of incorrect predictions for a computational model). I want to find the values of i,e when there is the minimum number of incorrect predictions. In other words, the value of "i" and

Re: [R] If find x, then y, else do nothing

2011-08-08 Thread Edward Patzelt
; >> >> >> require(car) >> >> foo <- function(x) { >> >> if (any(grepl(4, x))) { >> >>x <- recode(x, "2 = 1; 4 = 2") >> >> } >> >> return(x) >> >> } >> >> >> >> da

Re: [R] If find x, then y, else do nothing

2011-08-08 Thread Edward Patzelt
tasets > [8] methods base > > other attached packages: > [1] car_2.0-9 survival_2.36-5 nnet_7.3-1 MASS_7.3-11 > > again without issue, so I am thinking there must be something > particular perhaps to your session going on, but it is difficult to > say. > > On Mo

Re: [R] If find x, then y, else do nothing

2011-08-08 Thread Edward Patzelt
4165L, 4166L, 4167L, > 4168L, 4169L, 4170L, 166L, 167L, 168L, 169L, 170L, 171L, 172L, > 173L, 174L, 175L), class = "data.frame") > > Does that work for you? I am running: > > R Under development (unstable) (2011-07-30 r56564) > Platform: x86_64-pc-mingw32/x64 (64-bi

Re: [R] If find x, then y, else do nothing

2011-08-08 Thread Edward Patzelt
t attached): [1] cluster_1.13.3 grid_2.12.2 lattice_0.19-17 tools_2.12.2 On Mon, Aug 8, 2011 at 10:43 AM, Joshua Wiley wrote: > On Mon, Aug 8, 2011 at 8:23 AM, Edward Patzelt wrote: > > Thanks Josh for the code to post I have been trying to figure out how to > do > > that. Your cod

Re: [R] If find x, then y, else do nothing

2011-08-08 Thread Edward Patzelt
unction(x) { if (any(grepl(4, x))) { x <- recode(x, "2 = 1; 4 = 2") } return(x) } ## do it dat$test <- with(dat, *ave*(Slide1_RESP, Subject, FUN = foo)) On Fri, Aug 5, 2011 at 4:56 PM, Joshua Wiley wrote: > On Fri, Aug 5, 2011 at 2:34 PM, Edward Patzelt wrote: > >

Re: [R] If find x, then y, else do nothing

2011-08-05 Thread Edward Patzelt
resumably it is clearer with data. > In any event, look at ?ifelse it is something like a vectorized if > statement and is, I believe, preferable to your use of a for loop. I > can probably give you a runnable solution if you can give the first > few rows of the relevant data. > &

[R] If find x, then y, else do nothing

2011-08-05 Thread Edward Patzelt
I want to write code that says "If you find an element equal to 4 in this vector for each person in the data set tested separately, then put in 1 for 2 and 2 for 4, else leave the variable as is" u.ppl <- (unique(init.dat1$grid)) l.ppl <- length(u.ppl) for (i in 1:l.ppl) {

[R] Hidden Markov Models in R

2011-07-27 Thread Edward Patzelt
R Community - I am attempting to fit a model as described in Hampton, Bossaerts, and O'doherty (J. Neuroscience) 2006. They use a bayesian hidden markov model to model the Reversal Learning data. I have tried using HMM and depmixS4 with no success. My data is a Reversal Learning Task in which t

Re: [R] Loop through each subject

2011-06-28 Thread Edward Patzelt
- On Tue, Jun 28, 2011 at 1:27 PM, David Winsemius wrote: > > On Jun 28, 2011, at 1:44 PM, Edward Patzelt wrote: > > R help - >> >> I am attempting to write a script that has multiple subjects in 1 data >> file. >> Each subject has multiple rows with colum

[R] Loop through each subject

2011-06-28 Thread Edward Patzelt
R help - I am attempting to write a script that has multiple subjects in 1 data file. Each subject has multiple rows with columns as variables. Here is my code, I am having problem executing it on each unique subject id (dat$Subject). getwd() setwd("/Users/edwardpatzelt/Desktop/Neuroimaging

Re: [R] nlme Output

2010-09-06 Thread Edward Patzelt
f. > ~ Sir Ronald Aylmer Fisher > > The plural of anecdote is not data. > ~ Roger Brinner > > The combination of some data and an aching desire for an answer does not > ensure that a reasonable answer can be extracted from a given body of > data. > ~ John Tukey > > &g

[R] nlme Output

2010-09-06 Thread Edward Patzelt
Everyone - What do the NaN's mean here? Is this analysis a problem? Linear mixed-effects model fit by maximum likelihood Data: tmp.dat AIC BIClogLik 1611.251 1638.363 -797.6253 Random effects: Formula: ~1 | group_id (Intercept) Residual StdDev: 0.0003077668 9.23671