[R] Quantreg - 'could not find functionrq'
Hi all, I'm having some troubles with the Quantreg package. I am using R version 2.10.0, and have downloaded the most recent version of Quantreg (4.44) and SparseM (0.83 - required package). However, when I try to run an analysis (e.g. fit1-rq(y~x, tau=0.5)) I get an error message saying that the function rq could not be found. I get the same message when I try to search for any of the other functions that should be in the package (e.g. help(anova.rq)). I used this package last year and still have the old versions of both quantreg and SparseM saved on my machine. When I load these older packages and attempt an analysis (which, incidentally, worked fine last February) I get the same error messages as I do with the new versions. The only think I have changed since last February is the version of R I am using - is there any reason why quantreg wouldn't work in version 2.10.0? I'm not very experienced with R so I'm struggling to work out what may be going wrong - does anyone have any suggestions!? Many thanks Lauren --___ Lauren Gough - Postgraduate Research Student University of Nottingham, School of Geography, Nottingham, NG7 2RD Tel: +44 (0)115 8467052 Email: lgx...@nottingham.ac.uk mailto:lgx...@nottingham.ac.uk P Consider the environment. Please don't print this e-mail unless you really need to. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. [[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.
[R] Dividing a pixel image into factors - (cut.im(), cut.default())
Hi, I have a numeric pixel image which I would like to divide into factors for analysis in Spatstat. I have found that I can use cut.im() function to divide the range of pixel values into a series of equal length intervals (e.g. if my pixels values range from 0 to 60, cut.im(X.im,breaks=2) will produce two factors one containing pixel values 0-30 and one containing pixel values of 30 - 60, or thereabouts). However, I would like to specify the pixel value at which the factors are created - e.g. create one factor containing pixel values of 0-5 and another factor containing all other pixel values. I have been struggling to work out how to do this using either cut.im() or cut.default(). Can anyone help? Many thanks, Lauren This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. [[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.
[R] Fitting power laws to size distribution data
Hi, I have several datasets recording the size of individuals shrubs. I would like to test various distribution functions to see which fits my data most closely. So far I have used the fitdistr tool in the MASS package to get the parameter estimates for the best-fit lognormal, exponential and two-paramater Weibull functions. I have compared the fit of these functions using AIC. I would also like to fit a power function of the form f(D) = kD(^-r) (this is the form most of the relevant literature uses) obtaining estimates of the exponent (r). However, the power function does not appear to be supported by fitdistr. I have searched the forums and the internet and found a few ways of fitting power functions, but having run them they are giving me wildly different exponent estimates. Can anyone suggest a relaible way of fitting power functions? Many thanks Lauren This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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] Spatstat - K2 index
Hi all, I'm using spatstat to investigate the spatial structure of an arid shrub population. The first-order intensity of my data does not appear to be homogenous, so I would like to use inhomogeneous techniques. I realise there is a inhomogeneous K-function available in spatstat, but there doesn't not appear to be one for the pair-correlation function (O-ring statistic). As such I was planning to use a new technique (the K2 index) as described in Schiffers et al. (2008) [Ecography, 31:545-555]. The following website has more detail [http://www.oikos.ekol.lu.se/appendixdown/E5374-example.R]. Despite this I cannot get the function to run! I am not very familiar with R so it is likely my problem is simple. Does anyone have any experience with the K2-index who can give me some pointers? Many thanks Lauren This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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] Spatstat help - quadratcount query
Hi, No the output isn't the same as the original spatstat output, I changed it from scientific to numerical notation in excel. I realised last night that it was probably a rounding issue and have just performed the same analysis (in a much more long-winded way) in arcmap and got the same results, so quadratcount is producing 15m x 15m quadrats! Sorry to cause confusion! Is the quadratcount only when the results are plotted? I assume the numerical output (show(q15)) is correct? Best Lauren -Original Message- From: Adrian Baddeley [mailto:[EMAIL PROTECTED] Sent: 23 October 2008 05:34 To: R-help Forum Cc: Gough Lauren; Rolf Turner Subject: Re: [R] Spatstat help - quadratcount query Gough, Lauren wrote: I am using quadratcount in spatstat to divide a window containing a point pattern into a grid of quadrats containing the intensity of points in each quadrat. However, when I look at the data for quadrat counts it seems the function is not keeping the size of the quadrats constant, but is instead varying the width of the quadrats (in both the x and y direction) between 10m and 20m, meaning that some quadrats are 10m x 10m and some are four times the size (20m x 20m) (I have pasted some of the output below to demonstrate). This isn't exactly the pasted output from spatstat, is it? The output from spatstat for this window would look something like this: x y [3.4171e+05,3.4172e+05] (3.4172e+05,3.4174e+05] (3.12676e+06,3.12678e+06] 1 0 (3.12675e+06,3.12676e+06] 0 2 (3.12674e+06,3.12675e+06] 0 0 and so on. The row and column labels indicate the boundaries of the quadrats; however, because the coordinates are large numbers, they have been formatted in scientific notation, and ROUNDED to the fourth or fifth decimal place. A number printed as 3.12675e+06 is not always exactly equal to 3126750. It could be anywhere from 3126745 to 3126755. The peculiar impression that the successive differences alternate between 10 and 20, when they should be 15, is an artefact of the rules used for rounding numbers in R. To extract the precise values of the quadrat boundaries, use xbreaks - attr(q15, xbreaks) ybreaks - attr(q15, ybreaks) Then you can check directly that the breaks are evenly spaced at intervals of 15 units in each direction. Incidentally, please be warned that there is a bug in the plot method plot.quadratcount in spatstat 1.14-4 which causes the counts to be plotted in the wrong quadrats. This will be fixed in the next release spatstat 1.14-5, due shortly. Adrian Baddeley This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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] Spatstat help - quadratcount query
Hi all, I am using quadratcount in spatstat to divide a window containing a point pattern into a grid of quadrats containing the intensity of points in each quadrat. My data is in UTM co-ordinates. My window is defined as follows: p15-ppp(x,y,window=owin(c(341710,342100),c(3126465,3126780)),marks=NUL L, checks=TRUE) Giving me a distance of 390m in the 'x' direction and 315m in the 'y' direction. I want to divide the window into quadrats of size 15m x 15m so I did the following: q15-quadratcount(p15,nx=26,ny=21). However, when I look at the data for quadrat counts it seems the function is not keeping the size of the quadrats constant, but is instead varying the width of the quadrats (in both the x and y direction) between 10m and 20m, meaning that some quadrats are 10m x 10m and some are four times the size (20m x 20m) (I have pasted some of the output below to demonstrate). This is quite concerning as I am trying to ascertain the scale of variation in my point pattern density - I cannot do this if the quadrat scale does not stay constant!! Does anyone know how to make quadratcount produce equally sized quadrats? Many thanks Lauren ymin3126470 3126480 3126500 3126510 3126530 ymax3126480 3126500 3126510 3126530 3126540 xminxmax 341710 341720 0 1 0 0 0 341720 341740 0 0 3 1 5 341740 341750 0 1 2 1 3 341750 341770 2 1 0 0 1 341770 341780 4 6 5 4 0 341780 341800 1 4 2 1 1 341800 341810 0 0 1 5 1 341810 341830 0 0 0 1 3 341830 341840 4 1 3 0 0 341840 341860 1 1 0 0 2 341860 341880 4 2 0 0 3 341880 341890 3 2 0 5 1 341890 341900 3 2 0 4 1 341900 341920 3 2 2 0 0 341920 341930 0 3 2 3 0 341930 341950 1 5 2 2 4 341950 341960 0 0 6 3 2 341960 341980 0 0 0 3 2 341980 341990 0 0 0 0 0 341990 342010 0 0 3 0 0 342010 342020 1 0 0 0 0 342020 342040 1 1 1 1 2 342040 342050 1 0 0 0 2 342050 342070 1 0 0 0 0 342070 342080 1 0 0 0 0 342080 342100 0 0 0 0 0 This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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] Fitting weibull, exponential and lognormal distributions to left-truncated data.
Dear All, I have two questions regarding distribution fitting. I have several datasets, all left-truncated at x=1, that I am attempting to fit distributions to (lognormal, weibull and exponential). I had been using fitdistr in the MASS package as follows: fitdistr-(x,weibull) However, this does not take into consideration the truncation at x=1. I read another posting in this forum that suggested using the argument lower to truncate the distribution fitting. However, this does not seem to be working. For example, when I attempt to fit a weibull distribution truncated at x=1 using lower, it seems to set the best-fit shape parameter at 1: fitdistr(x,weibull,lower=1) shapescale 1. 9.87964337 (0.02358731) (0.40649570) ##I have tried this on other datasets also truncated at x=1 and get the same result (i.e. shape=1). Does anyone know how to successfully fit the exponential, weibull and lognormal distributions to truncated data? Secondly, as my datasets are large (1000 data points) assessing the fit of the distribution with kolmogorov smirnov goodness of fit tests is routinely showing statistical significance for all distributions. Therefore, I would like to plot the observed data with the theoretical best fit distributions (weibull, exponential and lognormal) to visually assess which fits the observed data best. So far I have been doing this as follows: fitdistr(x,weibull) shapescale a b D1-density(x) ##density distribution of observed data D2-density(rweibull(1500,shape=a,scale=b)) ##density of a random variable following the theoretical best fit weibull distribution with shape parameter =a, scale parameter = b. plot(range(D1$x),range(D1$y,D2$y),type=n,xlab=x,ylab=Density) lines(D1,col=red) lines(D2,col=blue) This successfully plots the two density curves on the same graph, but it plots data below the x=1 threshold - even for the observed data! I have tried limiting the scale of x-axis using xlim=c(1,150) but the graph still plots the origin of the graph as (0,0). I can only get different origins if I limit x more extremely e.g. xlim=c(50,150). Does anyone know how I can successfully change the origin of the graph to (1,0)? Sorry for the long e-mail! Any help would be greatly appreciated. Regards, Lauren This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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] Graphics winder keeps disappearing!
Dear all, I am a very new user to R (for windows) (since Monday!) so please excuse me if I am asking an obvious question! I am experiencing some problems with the graphics window - in short, it keeps disappearing. i.e. I can type x-c(1,3,6,4,9) plot(x) No errors are produced, but not graphics window appears either. The graphics window tends to work if I plot graphs immediately after opening R, but after I have had R open for a while and have run several functions/loaded datasets it stops appearing. Does anyone know why this is, I am a little confused! Many thanks Lauren PhD student School of Geography University Park University of Nottingham NG7 2RD This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. __ 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.