Below are the solutions to these exercises on “Non-Linear Model in R.” ############### # # # Exercise 1 # # # ############### # load data file Mussel <- read.csv(file.choose()) mussel.nls1 <- nls(SPECIES ~ a * AREA^b, start = list(a = 0.1, b = 1), data = Mussel) summary(mussel.nls1) ## ## Formula: SPECIES ~ a * […]

## Non-Linear Models in R: Exercises

A mechanistic model for the relationship between x and y sometimes needs parameter estimation. When model linearisation does not work,we need to use non-linear modeling. There are three main differences between non-linear and linear modeling in R: 1. Specify the exact nature of the equation. 2. Replace the lm() with nls(), which means non-linear least […]

## Polynomial Model in R – Study Case: Solutions

Below are the solutions to these exercises on “Polynomial Models in R – Solutions.” if (!require(car)){install.packages(car, dep=T)} library(car) ############### # # # Exercise 1 # # # ############### # load data file mussel<-read.csv(file.choose()) str(mussel) ## ‘data.frame’: 25 obs. of 3 variables: ## $ AREA : num 516 469 462 939 1357 … ## $ SPECIES: […]

## Polynomial Model in R – Study Case: Exercises

It is pretty rare to find something that represents linearity in the environmental system. The Y/X response may not be a straight line, but humped, asymptotic, sigmoidal or polynomial are possibly, truly non-linear. In this exercise, we will try to take a closer look at how polynomial regression works and practice with a study case. […]

## Simple Spatial Modeling – Part 3: Solutions

Below are the solutions to these exercises on “Simple Spatial Modeling – Part 3.” ############### # # # Exercise 1 # # # ############### ntimesteps <- 1000 ncell <- 25 timestep <- 1 t <- 0 k <- 0.01 ############### # # # Exercise 2 # # # ############### H <- matrix(data = 1,nrow=ncell,ncol=ncell) ############### […]

## Simple Spatial Modeling – Part 3: Exercises

So far, we have learned how to count spatial variability in our model. Please look at these two previous exercises here and here if you haven’t tried it yet. However, it only represents 1-Dimension models. In this exercise, we will try to expand our spatial consideration into a 2-Dimension model. Have a look at this […]

## Simple Spatial Modeling – Part 2: Solutions

Below are the solutions to these exercises on “Simple Spatial Modeling: Part 2.” ############### # # # Exercise 1 # # # ############### rm(list=ls()) t <- 0 ntimesteps <- 500 timestep <- 1 ncell <- 5 H <- mat.or.vec(ntimesteps+1,ncell) q <- mat.or.vec(1,ncell+1) # # ****** Here we define the flows q1 and q6 that remain […]

## Simple Spatial Modeling – Part 2: Exercises

In the first exercise of simple spatial modeling here, we learned to create a model that considers more spatial variability. However, it relies on an isolated system where we set the q1 and q6 as zero. In this exercise, we try to bring the model into a more realistic space by adding some boundary conditions, […]

## Simple Spatial Modeling – Part 1: Solutions

Below are the solutions to these exercises on “Simple Spatial Modeling – Part 1.” rainfall <- read.table(“C:/Users/Hanif Kusuma/Documents/R Blogging/spatial/rain.txt”) plot(x = (rainfall[,1]), y = rainfall[,2], xlab = “Time (sec)”, ylab = “Water level (cm)”, main = “Plot of simulated water level in tank”) ############### # # # Exercise 1 # # # ############### #define the […]

## Simple Spatial Modeling – Part 1: Exercises

This exercise is an extension of the last two previous exercises about numerical modeling. They can be found here and here. Those two previous exercises are representing how the model works in a lumped system. At this time, we will try to bring a space into our model. Make sure that you look at the […]