[R] browser always enters debug mode

2014-04-08 Thread Paul Murtaugh
This is something peculiar about the environment on one particular linux 
box, because it doesn't happen on other computers.  Whenever I invoke 
browser() inside a function, it automatically enters debugging mode, 
with line-by-line execution of code:

  dum - function() { browser(); x - rnorm(10); print(x) }
  dum()
Called from: dum()
Browse[1]
debug at #1: x - rnorm(10)
Browse[2]
debug at #1: print(x)
Browse[2]
  [1] -0.41466890  0.02276493  1.01332894 -2.72784447  0.73471652 0.41360718
  [7]  1.67942142 -1.47384724  1.12129541 -1.13447881
  isdebugged(dum)
[1] FALSE

Thanks in advance for any tips on how to revert to the normal browser() 
behavior.
-Paul


[[alternative HTML version deleted]]

__
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.


Re: [R] browser always enters debug mode

2014-04-08 Thread Paul Murtaugh
It appears to be a difference between versions 2.* and 3.* in the way 
that a newline ('enter') is handled at the browser prompt. Formerly, it 
would continue execution of the function; now it kicks you into 
debugging mode.  To get the old behavior, you need to enter 'c' at the 
browser prompt.


On 04/08/2014 12:34 PM, I wrote:

This is something peculiar about the environment on one particular linux
box, because it doesn't happen on other computers.  Whenever I invoke
browser() inside a function, it automatically enters debugging mode,
with line-by-line execution of code:

   dum - function() { browser(); x - rnorm(10); print(x) }
   dum()
Called from: dum()
Browse[1]
debug at #1: x - rnorm(10)
Browse[2]
debug at #1: print(x)
Browse[2]
   [1] -0.41466890  0.02276493  1.01332894 -2.72784447  0.73471652 0.41360718
   [7]  1.67942142 -1.47384724  1.12129541 -1.13447881
   isdebugged(dum)
[1] FALSE

Thanks in advance for any tips on how to revert to the normal browser()
behavior.
-Paul



__
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.


[R] error options

2011-12-28 Thread Paul Murtaugh

Hi,

I'm running simulations that include a function that occasionally fails
because of an unpredictable singularity in a matrix that it tries to invert.
I'd like to have the function return 'NA' when that happens, so that the
simulations can continue.  I've tried things like:

   test - function() {
   options(error=return(NA))
   x - solve(0)
   return(x)
   }

which does return 'NA'.  But it returns 'NA' whether or not there's an
error in the function:

   test - function() {
   options(error=return(NA))
   x - 0
   return(x)
   }

   test()
   [1] NA

What am I missing here?

Thanks in advance
-Paul

__
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.


[R] What BIC is calculated by 'regsubsets'?

2008-12-20 Thread Paul Murtaugh
The function 'regsubsets' appears to calculate a BIC value that is 
different from that returned by the function 'BIC'.  The latter is 
explained in the documentation, but I can't find an expression for the 
statistic returned by 'regsubsets'.


Incidentally, both of these differ from the BIC that is given in Ramsey 
and Schafer's, The Statistical Sleuth.  I assume these are all linear 
transformations of each other, but I'd like to know the 'regsubsets' 
formula (so that I can develop a way to do all-subsets selection based 
on the AIC rather than the BIC).


The following code defines a function that illustrates the issue.
Thanks
-Paul


script.ic - function() {

library(datasets)
print(names(airquality))  # Ozone Solar.R Wind Temp Month Day

# Fit a model with two predictors
mod1 - lm(Ozone ~ Wind + Temp, data=airquality)
npar - length(mod1$coef)+1 # no. parameters in fitted model,
#   including s2, is 4
nobs - length(mod1$fitted) # no. of observations = 116
s2 - summary(mod1)$sigma2 # MSE = 477.6371
logL - as.vector(logLik(mod1)) # log likelihood = -520.8705

# Use the R function BIC, defined as: -2*log-likelihood + npar*log(nobs)
tmp1 - BIC(mod1)   # 1060.755
tmp2 - -2 * (-520.8705) + 4 * log(116) # 1060.755, agrees
cat(paste(\nFrom R's BIC:,signif(tmp1,5),(,signif(tmp2,5),
   obtained 'by hand')\n\n))

# Now see how 'regsubsets' calculates the BIC
tmp3 - regsubsets(Ozone ~ Solar.R + Wind + Temp, data=airquality)
tmp3.s - summary(tmp3)

# 'mod1' is the second model in 'tmp3'; what is the formula for this BIC?
cat(\nThe corresponding model from 'regsubsets':\n)
print(tmp3.s$which[2,])
tmp4 - tmp3.s$bic[2]   # -82.52875
cat(paste(\nBIC =,signif(tmp4,5),\n))

# Incidentally, the 'rsq' and 'rss' components of tmp3.s do not agree
# with the values in the 'mod1' lm output object.

# Just for kicks, try the formula for Schwarz's BIC from Ramsey  Schafer,
# Statistical Sleuth:  nobs*log(MSE) + npar*log(nobs))
tmp5 - 116 * log(477.6371) + 4*log(116)# 734.6011
cat(paste(\nStat. Sleuth's BIC =,signif(tmp5,5),\n))
cat(\nUff da!\n)

browser()

}

__
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.


[R] slow graphics download

2008-10-20 Thread Paul Murtaugh

Hi,

I often work from home, running R on my office computer and displaying 
interactive graphics on my home computer using X11.  This was always 
more sluggish than sitting at my office computer, obviously, but 
recently the graphics transfer has become painfully slow -- so slow, 
that I now divert the images to a postscript file and display that file 
remotely (which takes a second or two).


I don't know what changed between the old days and now -- I may have 
installed a new version of R and updated the o.s. (ubuntu) on both 
computers, but am unsure of the timing.  I realize this makes 
troubleshooting difficult, but I am hoping someone can offer a tip on 
where to begin.


Thanks
-Paul

__
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.


[R] ubuntu installation: can't find ldpaths

2008-09-24 Thread Paul Murtaugh
I'm trying to install R under Ubuntu 7.10 (gutsy; Linux 
2.6.22-15-generic x86_64). Following the instructions at 
http://cran.r-project.org/bin/linux/ubuntu/README, I installed r-base, 
r-base-core, and r-base-dev without any problems. When I open R, 
however, I get the message Can't open /usr/lib64/R/etc/ldpaths.


That file is linked to /etc/R/ldpaths, which doesn't exist on my system.

  root# ls -l /usr/lib64/R/etc/ldpaths
  2008-09-24 13:44 /usr/lib64/R/etc/ldpaths - /etc/R/ldpaths
  root# ls /etc/R
  root#

In fact, there doesn't appear to be an 'ldpaths' file anywhere, other 
than a link to /etc/R/ldpaths from another directory.


  root# find / -name 'ldpaths' -print
  /usr/lib/R/etc/ldpaths
  [EMAIL PROTECTED]:~# ls -l /usr/lib/R/etc/ldpaths
  2008-09-24 13:44 /usr/lib/R/etc/ldpaths - /etc/R/ldpaths

Can anyone help?  Thanks in advance.

-Paul

__
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.