I am trying to find the spectral density of an MA(2) model using R. This is the formula I came up with but R is telling me there is an "attempt to apply non-function" error. Can't find where I went wrong. Help.
specdensity=
(sigma^2 + ((theta1^2)*(sigma^2))+
((theta2^2)*(sigma^2))+
2(theta1*(sigma^2)+(theta1*theta2*sigma^2))*(cos(2*pi*omega))+
2((theta2*sigma^2)*(cos(4*pi*omega))))
Also sigma, theta1, theta2, and omega have all been defined. Where is my mistake? Thank you.