i trying plot interaction term linear mixed effects model using effects plot. see example below:
library(nlme) fita <- lme(pee ~ pupper*max_depth, random=~1 + pupper|ref, data=m4, cor=corar1(), method="ml") pupper continuous variable , max_depth factorial variable (5 levels - 400,500,600,700,800).
when plot model output in effects plot interaction term able show how relationship between pee , pupper changes according different factors levels of max_depth:
library(effects) plot(effect("pupper*max_depth",fita), xlab=expression(paste("d"[-5]," p"[upper]," (m"^" -1",")")), ylab=expression(paste("pee rate (h"^" -1",")")), factor.names=false, layout=c(5,1), alternating=false, main="a", ticks.x=list(pupper=list(at=seq(0.4,1.0,0.2))), ##layout(matrix(c(2,0,1,3),2,2,byrow=true), c(3,1), c(1,3), true) rotx=45, more=false, grid=false, lwd=1) 
however, when plot similar model effects plot change how want interaction displayed (see below). in effects plot below, plot 'decides' display relationship between pee , max_depth , how changes according arbitrary division of continuous variable pupper (labeled plower in code , 'k150' in plot shown below):
fitb <- lme(pee ~ plower*max_depth, random=~1 + plower|ref, data=m4, cor=corar1(), method="ml") plot(effect("plower*max_depth",fitb), xlab=expression(paste("d"[-5]," p"[lower]," (m"^" -1",")")), ylab=expression(paste("pee rate (h"^" -1",")")), factor.names=false, layout=c(5,1), alternating=false, main="a", ticks.x=list(plower=list(at=seq(0.4,1.0,0.2))), ##layout(matrix(c(2,0,1,3),2,2,byrow=true), c(3,1), c(1,3), true) rotx=45, more=false, grid=false, lwd=1) 
however, interested in how factor max_depth influences relationship between pee , plower (similar first figure above). cannot work out why effect function displays same interaction term in 2 different ways. love know how control way interaction term represented in effect plot problem keeps popping ugly head up.
below subset of dataset:
structure(list(ref = c("2012-3corrige", "2011-28", "2011-26", "2011-21", "2011-21", "2013-7", "2012-1corrige", "2012-6corrige", "2013-4", "2011-21", "2013-10", "2013-4", "2013-13", "2011-26", "2013-11", "2012-3corrige", "2013-1", "2012-14corrige", "2013-1", "2011-27", "2012-6corrige", "2011-18", "2011-26", "2010-18", "2012-14corrige", "2011-21", "2013-6", "2013-11", "2011-27", "2011-18", "2012-16corrige", "2013-5", "2013-13", "2011-21", "2012-14corrige", "2013-5", "2013-18", "2012-16corrige", "2011-28", "2010-18", "2011-21", "2013-2", "2012-2corrige", "2013-4", "2013-5", "2013-11", "2011-21", "2013-6", "2011-28", "2013-6", "2010-18", "2011-21", "2013-18", "2011-16", "2012-11corrige", "2011-28", "2011-27", "2012-3corrige", "2012-2corrige", "2013-3", "2012-1corrige", "2012-14corrige", "2012-14corrige", "2013-10", "2012-6corrige", "2010-18", "2012-11corrige", "2013-7", "2013-2", "2012-16corrige", "2013-1", "2013-18", "2012-16corrige", "2013-6", "2012-4corrige", "2013-4", "2013-10", "2013-3", "2013-2", "2011-16", "2012-1corrige", "2011-21", "2011-21", "2013-18", "2013-3", "2011-26", "2010-18", "2013-13", "2012-6corrige", "2013-3", "2012-16corrige", "2012-15corrige", "2011-28", "2012-6corrige", "2012-6corrige", "2012-11corrige", "2013-1", "2013-11", "2012-11corrige", "2013-6"), pupper = c(0.861958207287982, 0.824829924556841, 0.958739109455748, 0.935401831656677, 0.955566680038604, 0.948368978826279, 0.745071680369673, 0.827539122942233, 0.726448658429027, 0.943103302931338, 0.858445846226439, 0.784802718309937, 0.881010495586365, 0.911770168408684, 0.90971638692581, 1.02155421458351, 0.851778844536538, 1.1553118943962, 0.887452083213511, 0.8218157295485, 0.871777265131409, 0.829892474962871, 1.01579427707254, 0.715539162683171, 1.12624787680155, 0.713105471394893, 0.802478037082636, 0.773243110590944, 0.762028205952159, 0.785089166910358, 0.844285844170484, 0.887514023676371, 0.870367623478723, 0.820303824472643, 0.636099278958915, 0.953776661488422, 0.816485694234068, 0.861493535070196, 0.787945463425822, 0.918041865421543, 0.877275056321815, 0.624152855209897, 0.971197595182818, 0.769613695304339, 0.941443459091764, 0.929070549770906, 1.031203743205, 0.692597025693873, 0.846978945035432, 0.72446749179426, 0.541564092852052, 0.744921803502444, 0.917786983273715, 0.702051561892398, 0.975310403563878, 0.808819367281032, 0.858040403089116, 0.741495941398947, 0.698143566897239, 0.979366380200314, 0.992046903013047, 0.995331870590213, 0.804437082665078, 0.8307554779262, 0.878549524310762, 0.654725061889849, 0.93024953667308, 0.654611447094126, 0.689696271315618, 0.77302453480932, 0.916283427766758, 0.894114399839305, 0.840205756601608, 0.767235548359607, 0.831544386468135, 0.685089269122402, 0.860269828471148, 0.895228365651283, 0.785946885397904, 0.812567650516969, 0.797256286689962, 0.800979891549511, 0.684467773772683, 0.846228645225391, 0.801015938251751, 0.964375424821682, 0.783654311543043, 0.951249150678552, 0.847095453102345, 0.782862048298847, 0.897798965949478, 0.79591714811698, 0.954852044385237, 0.885914708711347, 0.789575506205708, 1.10814372714012, 0.875651148193922, 0.851523408695002, 0.963324355206144, 0.795071091161036), plower = c(0.705132769215998, 0.667302197075824, 0.629978835623335, 0.632452896796802, 0.641619045851976, 0.634150350206216, 0.521875889886134, 0.69048678481199, 0.620155894379255, 0.72673011955379, 0.644805071164551, 0.691418831100224, 0.561990510002912, 0.702502669034076, 0.5885329988032, 1.06019049650942, 0.610499795249761, 0.863589408611907, 0.671649710290516, 0.7008237216939, 0.613070958372683, 0.52121652570373, 0.743727100487806, 0.619214556245787, 1.0217109832694, 0.653199816289013, 0.653255947797901, 0.629436452185155, 0.621227279933305, 0.581484689776476, 0.605084016204913, 0.670828674932066, 0.694246594037978, 0.732994239783339, 0.728155423409921, 0.657673931367209, 0.681945582710071, 0.656113353702447, 0.55299186250794, 0.589741939797023, 0.760512984767519, 0.550684422635445, 0.888934443277143, 0.615143614667881, 0.736486026117717, 0.616589579139919, 0.640405340389975, 0.618517043688639, 0.612475849864031, 0.681245183469212, 0.642477842246546, 0.683125578173995, 0.636702442275825, 0.568741300299764, 0.681781639762194, 0.58956858049858, 0.697614984548545, 0.773372843818268, 0.599073358520381, 0.653548263966276, 0.846172099647715, 0.946825538132655, 0.635504629303462, 0.61980005655224, 0.594418483337567, 0.610786378368084, 0.809715477703094, 0.596886365511337, 0.601414998150196, 0.680138336678131, 0.672368946338244, 0.693205917779446, 0.736742863266092, 0.636678882954351, 0.611664395999418, 0.630585706572337, 0.6554630468205, 0.617362130357864, 0.615793526002561, 0.688748462389895, 0.733587834625896, 0.715468455706547, 0.695921451506322, 0.649384323802169, 0.654685675216232, 0.675344356606317, 0.617759392212426, 0.620895052860519, 0.652138022200822, 0.638494322605926, 0.798451637031189, 0.884450865414997, 0.895823643358446, 0.661857655055493, 0.743487278528243, 0.88302132854573, 0.660494764046872, 0.638155299450374, 0.515272975866573, 0.636047692132176), pee = c(1.49625537031302, 0.579708304983786, 1.09755665230733, 0.79999598579792, 0.366971323405136, 0.534519852186464, 0.892172302701565, 0.764300080784289, 0.162161584516302, 1.05547854644252, 1.75994722974226, 0.502090519778478, 0.813556191910923, 0.72071830101183, 0.124737712452804, 0.24096278221797, 2.11763754191128, 0.0970872140009704, 0.214668546888839, 0.997227687637828, 0.449413221941473, 0.445533213208998, 0.719422276286327, 0.311417756794472, 0.0799998795735146, 0.836011454943211, 0.217381544231536, 0.131863894834852, 1.1881086717854, 0.562478645146688, 2.13755423670725, 0.260855398500945, 0.769228719926564, 0.792077729637109, 0.46631964160662, 0.727219913477435, 0.234599414042217, 1.24135448496734, 1.73912823566756, 0.437157161658986, 1.18491673172712, 1.57894265236866, 0.325374033367569, 0.133629870488068, 0.260855348600893, 0.279711624960117, 1.04650548272943, 1.13790951622142, 0.512819441159373, 2.51301278595252, 0.948078086013639, 0.183485515251287, 0.521708195407091, 0.834371581292816, 0.907354231373586, 0.263735732207326, 0.94736384877553, 0.865382874911045, 0.162378076290205, 1.80685106084338, 1.07131194190618, 1.20567188480079, 1.01009693910426, 0.352933736835024, 0.315767760495837, 0.901500577761704, 1.08481956174672, 0.553504151294972, 1.81542854475215, 2.23136249824668, 0.14018646847029, 0.58250584995577, 1.74754206600435, 0.404021461283339, 1.0507621403718, 3.1578487818322, 1.23592560921063, 0.428569941841892, 2.59927399028359, 0.462953155929056, 1.60334686111772, 0.610996390428844, 0.93749693604517, 0.374210416022193, 0.596024133599949, 1.07142175386991, 0.233917466116807, 0.773637607411201, 0.733915433670645, 0.693195231932592, 0.699678270730694, 0.75104196328333, 1.1707299559812, 0.376558572007052, 1.5725384212365, 0.17424722659426, 0.481925512179189, 0.127383975172354, 0.449990814000021, 0.828701950628209), max_depth = structure(c(5l, 1l, 5l, 5l, 3l, 2l, 3l, 2l, 2l, 2l, 2l, 5l, 3l, 3l, 3l, 4l, 5l, 1l, 5l, 1l, 5l, 2l, 4l, 3l, 3l, 3l, 3l, 2l, 4l, 2l, 2l, 5l, 2l, 2l, 4l, 5l, 4l, 2l, 1l, 5l, 2l, 1l, 4l, 4l, 4l, 3l, 4l, 1l, 2l, 2l, 5l, 5l, 4l, 1l, 3l, 1l, 3l, 2l, 4l, 1l, 5l, 1l, 5l, 4l, 4l, 1l, 2l, 4l, 1l, 1l, 4l, 4l, 2l, 2l, 2l, 4l, 2l, 5l, 1l, 2l, 1l, 3l, 4l, 3l, 1l, 5l, 1l, 4l, 4l, 3l, 3l, 3l, 1l, 3l, 1l, 1l, 4l, 1l, 4l, 2l), .label = c("400", "500", "600", "700", "800"), class = "factor"), fangle = structure(c(2l, 3l, 1l, 4l, 3l, 4l, 3l, 3l, 3l, 3l, 2l, 4l, 2l, 4l, 2l, 4l, 4l, 4l, 4l, 1l, 4l, 2l, 2l, 4l, 3l, 4l, 4l, 2l, 2l, 2l, 4l, 3l, 3l, 4l, 1l, 3l, 4l, 2l, 3l, 3l, 4l, 3l, 2l, 3l, 3l, 3l, 2l, 1l, 2l, 2l, 3l, 3l, 2l, 2l, 2l, 3l, 2l, 4l, 1l, 3l, 2l, 4l, 3l, 3l, 1l, 2l, 2l, 4l, 2l, 1l, 4l, 3l, 4l, 2l, 4l, 3l, 4l, 4l, 3l, 2l, 3l, 3l, 2l, 2l, 4l, 2l, 4l, 4l, 3l, 4l, 3l, 4l, 1l, 4l, 4l, 4l, 2l, 2l, 3l, 3l), .label = c("0", "20", "40", "60"), class = "factor")), .names = c("ref", "pupper", "plower", "pee", "max_depth", "fangle"), row.names = c(26297l, 18163l, 13367l, 10757l, 10813l, 43605l, 22984l, 27608l, 39808l, 11220l, 32882l, 39987l, 35960l, 13719l, 34174l, 25877l, 31747l, 19402l, 31394l, 14990l, 28537l, 9023l, 13684l, 1781l, 19411l, 9964l, 41834l, 33800l, 15277l, 8673l, 21864l, 40681l, 35425l, 11590l, 19901l, 40867l, 36845l, 21698l, 18302l, 470l, 11459l, 37414l, 24555l, 40026l, 40578l, 33627l, 9525l, 41816l, 17695l, 42057l, 294l, 9972l, 37137l, 8304l, 19086l, 15817l, 15351l, 26097l, 24896l, 39059l, 23703l, 20110l, 19937l, 32121l, 28556l, 13l, 19157l, 42865l, 37922l, 21887l, 31638l, 37008l, 21905l, 41848l, 26621l, 39864l, 32870l, 39107l, 37721l, 7969l, 23826l, 11903l, 12024l, 36500l, 38488l, 13287l, 462l, 36245l, 28096l, 38611l, 21500l, 20565l, 17140l, 27772l, 27773l, 18897l, 30992l, 34564l, 18553l, 41312l), class = "data.frame")
the data subset you've supplied insufficient fit models think can answer question. selection of variable on horizontal axis controlled x.var argument plot.eff(); ?plot.eff:
x.var: index (number) or quoted name of covariate or factor place on horizontal axis of each panel of effect plot. default predictor largest number of levels or values.
in turn, covariate values @ effect evaluated controlled xlevels argument effect(), in case called effect(); ?effect:
xlevels: argument used set number of levels focal predictor not factor. if xlevels=null, default, number , values of levels numeric predictor determined grid.pretty. if xlevels=n integer, each numeric predictor represented n equally spaced levels. more generally, xlevels can named list of values @ set each numeric predictor. example, xlevels=list(x1=c(2, 4, 7), x2=5) use values 2, 4 , 7 levels of x1, 5 equally spaced levels levels of x2, , use default other numeric predictors. if partial residuals computed, focal predictor appear on horizontal axis of effect plot evaluated @ 100 equally spaced values along full range, and, default, other numeric predictors evaluated @ quantiles specified in quantiles argument, unless values given explicitly in xlevels.
curiously, second plot show appears include variable, k150, doesn't appear in model.
i hope helps,
john
Comments
Post a Comment