Hi,
Why, when I run the script below, is my y-axis range command being ignored? 
I.e., the y axis graphed consistently fits the line specified in the plot
command, but never fits the line I'm trying to add in the subsequent line
command.
This is my first R script, so if I'm doing anything else wacky that jumps
out, please let me know.  I'm an advanced Stata user, but R is new to me.
The script is designed to simulate a binary-choice decision field theory
example with internally-controlled stop time, as per Neural Networks 19
(2006) 1047-1058.
Thanks in advance!!
-Dan


#-----------------
# Starting preference state; two choices
preference<-c(0,0)
# Preference threshold; when one of the preference states exceeds this
threshhold, deliberation stops
theta<- 2
# Contrast matrix
contrast<-array(c(1, -1, -1, 1), dim=c(2,2))
# Value Matrix; three possible states of the world
value<-array(c(1,0, 0, 1, .5,.5), dim=c(2, 3))
# Feedback Matrix
feedback<-array(c(1, .5, .5, 1), dim=c(2,2))

# Time
t<- array(0, dim=c(1,1))

# Arrays to keep track of history for graphing
time_for_graph<-array(t, dim=c(1,1))
preference_for_graph<-array(preference, dim=c(1,2))

# Moving through time until preference crosses the threshold theta
while (preference[1]<theta && preference[2]<theta) {  
        
        #stochastic weights for this time period
        weight<-rnorm(3,0,1)
        
        #updating preference
        preference<-feedback%*%preference + contrast%*%value%*%weight

        #updating history
        t<-t+1
        time_for_graph<-rbind(time_for_graph, t)
        preference_for_graph<-rbind(preference_for_graph, array(preference,
dim=c(1,2)))

        #updating graph ranges
        ry<-range(preference_for_graph)
        rx<-range(time_for_graph)

        #updating graph 
        plot(time_for_graph[,1], preference_for_graph[,1], type="b",
plot.window(rx, ry), xlab="Time", ylab="Preference")
        lines(time_for_graph[,1], preference_for_graph[,2], type="b", col="red",
ylim=ry)
}
#-------------
-- 
View this message in context: 
http://old.nabble.com/plot.window-arguments-being-ignored--tp26249609p26249609.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to