Changeset 825
- Timestamp:
- 08/03/11 17:48:38 (22 months ago)
- Location:
- MGET/Branches/Jason/PythonPackage/src/GeoEco/Statistics
- Files:
-
- 2 modified
-
FitLMEForDataframe.r (modified) (3 diffs)
-
Modeling.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
MGET/Branches/Jason/PythonPackage/src/GeoEco/Statistics/FitLMEForDataframe.r
r815 r825 18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 19 20 FitLMEForDataframe <- function(fixed, data, outputModelFile, random=NULL, correlation= NULL, method=NULL, xVar=NULL, yVar=NULL, zVar=NULL, mVar=NULL, coordinateSystem=NULL, writeSummaryFile=TRUE, plotFileFormat="png", res=1000.0, width=3000.0, height=3000.0, pointSize=10.0, bg="white")20 FitLMEForDataframe <- function(fixed, data, outputModelFile, random=NULL, correlation="NULL", method=NULL, xVar=NULL, yVar=NULL, zVar=NULL, mVar=NULL, coordinateSystem=NULL, writeSummaryFile=TRUE, plotFileFormat="png", res=1000.0, width=3000.0, height=3000.0, pointSize=10.0, bg="white") 21 21 { 22 22 # Fit the model. … … 32 32 "==============\n", 33 33 "\n", 34 paste(capture.output(summary(model)), sep="", collapse="\n"), "\n",34 sub("Fixed effects: list\\(fixed\\)", paste("Fixed effects: ", as.character(fixed)[2], as.character(fixed)[1], as.character(fixed)[3]), paste(capture.output(summary(model)), sep="", collapse="\n")), "\n", 35 35 "\n", 36 36 "ANOVA:\n", … … 43 43 # Write the output file. 44 44 45 save(model, xVar, yVar, zVar, mVar, coordinateSystem, file=outputModelFile, compress=FALSE)45 save(model, fixed, random, xVar, yVar, zVar, mVar, coordinateSystem, file=outputModelFile, compress=FALSE) 46 46 47 47 # Strip the extension, if one exists, off the output file path. -
MGET/Branches/Jason/PythonPackage/src/GeoEco/Statistics/Modeling.py
r824 r825 417 417 where=None, method=u'REML', correlationStructure=None, correlationFormula=None, range_=None, nugget=None, metric=None, fixed=False, 418 418 xColumnName=None, yColumnName=None, zColumnName=None, mColumnName=None, 419 writeSummaryFile=True, plotFileFormat=u'png', res=1000., width=3000., height=3000., pointSize=10.0, bg=u'white',419 writeSummaryFile=True, writeDiagnosticPlots=True, plotFileFormat=u'png', res=1000., width=3000., height=3000., pointSize=10.0, bg=u'white', 420 420 overwriteExisting=False): 421 421 cls.__doc__.Obj.ValidateMethodInvocation() 422 423 # Perform additional validation. 424 425 if correlationStructure is not None and correlationFormula is None or correlationStructure is None and correlationFormula is not None: 426 Logger.RaiseException(ValueError(_('To fit a model that includes for within-group correlation, you must specify both the a correlation structure and a correlation formula. If you do not wish to include within-group correlation, you must omit both of those parameters.'))) 427 428 if correlationStructure is not None and range_ is None and nugget is not None: 429 Logger.RaiseException(ValueError(_('If the Nugget parameter is specified, the Range parameter must also be specified.'))) 422 430 423 431 # Load the table into a temporary data frame. … … 439 447 randomFormula = u'NULL' 440 448 441 r('FitLMEForDataframe(fixed=%s, data=%s, outputModelFile="%s", random=%s, correlation=NULL, method="%s", xVar=%s, yVar=%s, zVar=%s, mVar=%s, coordinateSystem=%s, writeSummaryFile=%s, plotFileFormat="%s", res=%f, width=%f, height=%f, pointSize=%f, bg="%s")' % 442 (fixedFormula, dataFrameName, tempOutputFile.replace('\\', '\\\\'), randomFormula, method, 449 if correlationStructure is not None: 450 if correlationStructure == u'exponential': 451 correlation = u'corExp(' 452 elif correlationStructure == u'gaussian': 453 correlation = u'corGaus(' 454 elif correlationStructure == u'linear': 455 correlation = u'corLin(' 456 elif correlationStructure == u'rational quadratic': 457 correlation = u'corRatio(' 458 elif correlationStructure == u'spherical': 459 correlation = u'corSpher(' 460 else: 461 Logger.RaiseException(RuntimeError(_('Unknown correlationStructure value \'%(cs)s\'. Please contact the author of this tool for assistance.') % {u'cs': correlationStructure})) 462 463 if range_ is not None: 464 if nugget is None: 465 correlation += repr(range_) + ', ' 466 else: 467 correlation += u'c(' + repr(range_) + u', ' + repr(nugget) + u'), ' 468 469 correlation += u'form=' + correlationFormula + u', nugget=' + repr(nugget is not None).upper() 470 471 if metric is not None: 472 correlation += u', metric="' + metric + u'"' 473 474 correlation += u', fixed=' + repr(fixed).upper() + u')' 475 476 else: 477 correlation = u'NULL' 478 479 r('library(nlme)') # Required here so we can instantiate correlation classes 480 481 r('FitLMEForDataframe(fixed=%s, data=%s, outputModelFile="%s", random=%s, correlation=%s, method="%s", xVar=%s, yVar=%s, zVar=%s, mVar=%s, coordinateSystem=%s, writeSummaryFile=%s, plotFileFormat="%s", res=%f, width=%f, height=%f, pointSize=%f, bg="%s")' % 482 (fixedFormula, dataFrameName, tempOutputFile.replace('\\', '\\\\'), randomFormula, correlation, method, 443 483 xColumnParam, yColumnParam, zColumnParam, mColumnParam, coordinateSystemParam, 444 484 str(writeSummaryFile).upper(), plotFileFormat, res, width, height, pointSize, bg)) … … 3584 3624 3585 3625 AddArgumentMetadata(LinearMixedModel.FitToArcGISTable, u'correlationStructure', 3586 typeMetadata=UnicodeStringTypeMetadata(canBeNone=True, allowedValues=[u'Exponential', u'Gaussian', u'Linear', u'Rational quadratic', u'Spherical']),3626 typeMetadata=UnicodeStringTypeMetadata(canBeNone=True, makeLowercase=True, allowedValues=[u'Exponential', u'Gaussian', u'Linear', u'Rational quadratic', u'Spherical']), 3587 3627 description=_( 3588 3628 u"""TODO: Write documentation for this parameter."""),
