NavigationUser login 
dylan's blogInteresting R PackagesSubmitted by dylan on Mon, 20090427 15:47.
( categories: )
Comparison of Slope and Intercept Terms for MultiLevel Model II: Using ContrastsSubmitted by dylan on Tue, 20090217 04:43.
PremiseSmall update to a similar thread from last week, on the comparison of slope and intercept terms fit to a multilevel model. I finally figured out (thanks RHelp mailing list!) how to efficiently use contrasts in R. The C() function can be called within a model formula, to reset the base level of an unordered factor. The UCLA Stats Library has an extensive description of this topic here. This approach can be used to sequentially test for differences between slope and intercept terms from a multilevel model, by resetting the base level of a factor. See example data and figure below. Note that the multcomp package has a much more robust approach to this type of operation. Details below. # need these library(lattice) # replicate an important experimental dataset set.seed(10101010) x < rnorm(100) y1 < x[1:25] * 2 + rnorm(25, mean=1) y2 < x[26:50] * 2.6 + rnorm(25, mean=1.5) y3 < x[51:75] * 2.9 + rnorm(25, mean=5) y4 < x[76:100] * 3.5 + rnorm(25, mean=5.5) d < data.frame(x=x, y=c(y1,y2,y3,y4), f=factor(rep(letters[1:4], each=25))) # plot xyplot(y ~ x, groups=f, data=d, auto.key=list(columns=4, title='Beard Type', lines=TRUE, points=FALSE, cex=0.75), type=c('p','r'), ylab='Number of Pirates', xlab='Distance from Land') ( categories: )
Aggregating Soil Survey Information: Available Water Holding CapacitySubmitted by dylan on Sat, 20090131 23:53.
Horizon thicknessweighted mean AWC (available water holding capacity), aggregated to a 4km grid, based on the detailed (SSURGO) soil survey database. Each grid cell is the component percentage / area fraction weighted mean of profile AWC. The variation in AWC tracks several important parent material induced patterns: with lower AWC in residual soils formed on steep granitic terrain (south flank of Sierra Nevada), and higher AWC in residual soils formed on the gentler slopes of metavolcanic and metasedimentary terrain (central and northern flanks of Sierra Nevada). The higher AWC values one the east side of the San Joaquin Valley correspond with the characteristically finer soils formed from coast range alluvium. High AWC values of the Sacramento Valley correspond with the fine textured soils derived from a mixture of coast range alluvium, and metavolcanic/sedimentary alluvium from the Sierra Nevada. ( categories: )
Comparison of Slope and Intercept Terms for MultiLevel ModelSubmitted by dylan on Thu, 20090129 18:23.
PremiseWhen the relationship between two variable is (potentially) dependent on a third, categorical variable ANCOVA (analysis of covariance), or some variant, is commonly used. There are several approaches to testing for differences in slope/intercepts (in the case of a simple linear model) between levels of the stratifying variable. In R the following formula notation is usually used to test for interaction between levels of a factor (f) and the relationship between two continuous variables x and y: y ~ x * f. A simple graphical exploration of this type of model can be done through examination of confidence intervals computed for slope and intercept terms, for each level of our grouping factor (f). An example of a fictitious dataset is presented below. Note that this a rough approximation for testing differences in slope/intercept within a multilevel model. A more robust approach would take into account that we are trying to make several pairwise comparisons, i.e. something akin to Tukey's HSD. Something like this can be done with the multcomp package. For any real data set you should always consult a real statistician. # need this for xyplot() library(lattice) # make some fake data: x < rnorm(100, mean=3, sd=6) y < x * runif(100, min=1, max=7) + runif(100, min=1.8, max=5) d < data.frame(x, y, f=rep(letters[1:10], each=10)) # check it out xyplot(y ~ x  f, data=d, type=c('p','r')) ( categories: )
Some Ideas on Interpolation of Categorical DataSubmitted by dylan on Thu, 20090115 04:36.
PremiseWanted to make something akin to an interpolated surface for some spatially autocorrelated categorical data (presence/absence). I quickly generated some fake spatially autocorrelated data to work with using r.surf.fractal in GRASS. These data were converted into a binary map using an arbitrary threshold that looked about right splitting the data into something that looked 'spatially clumpy'. I had used voronoi polygons in the past to display connectivity of categorical data recorded at points, even though sparsely sampled areas tend to be over emphasized. Figure 1 shows the fake spatially autocorrelated data (grey = presence /white = not present), sample points (yellow boxes), and voronoi polygons. The polygons with thicker, red boundaries represent the "voronoi interpolation" of the categorical feature. ( categories: )
Some Interesting LinksSubmitted by dylan on Tue, 20081230 02:45.
( categories: )
Python Image Module Example: How much ink on that page?Submitted by dylan on Fri, 20081226 21:26.
( categories: )
Traveling Salesman Approach to Visiting Dataloggers IISubmitted by dylan on Tue, 20081223 01:46.
Traveling Salesman Approach to Visiting DataloggersSubmitted by dylan on Sat, 20081220 06:44.
( categories: )
Additive Time Series Decomposition in R: Soil Moisture and Temperature DataSubmitted by dylan on Mon, 20081027 16:08.
( categories: )
